Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

PostOfficeInput Class Reference

The class defines a "Post Office", or a collection of mailboxes. Receive -- wait until a message is in the mailbox, then remove and return it. Incoming messages are put by the PostOffice into the appropriate mailbox, waking up any threads waiting on Receive. More...

#include <post.h>

Inheritance diagram for PostOfficeInput::

CallBackObj List of all members.

Public Methods

 PostOfficeInput (int nBoxes)
 Allocate and initialize Post Office. More...

 ~PostOfficeInput ()
 De-allocate Post Office data. More...

void Receive (int box, PacketHeader *pktHdr, MailHeader *mailHdr, char *data)
 Retrieve a message from "box". Wait if there is no message in the box. More...

void PostalDelivery ()
 Wait for incoming messages, and then put them in the correct mailbox. More...

void CallBack ()
 Called when incoming packet has arrived and can be pulled off of network (i.e., time to call PostalDelivery). More...


Private Attributes

NetworkInputnetwork
 Physical network connection. More...

MailBoxboxes
 Table of mail boxes to hold incoming mail. More...

int numBoxes
 Number of mail boxes. More...

SemaphoremessageAvailable
 V'ed when message has arrived from network. More...


Detailed Description

The class defines a "Post Office", or a collection of mailboxes. Receive -- wait until a message is in the mailbox, then remove and return it. Incoming messages are put by the PostOffice into the appropriate mailbox, waking up any threads waiting on Receive.

Definition at line 104 of file post.h.


Constructor & Destructor Documentation

PostOfficeInput::PostOfficeInput ( int nBoxes )
 

Allocate and initialize Post Office.

PostOfficeInput::PostOfficeInput Initialize the post office input queues as a collection of mailboxes. Also initialize the network device, to allow post offices on different machines to deliver messages to one another.

We use a separate thread "the postal worker" to wait for messages to arrive, and deliver them to the correct mailbox. Note that delivering messages to the mailboxes can't be done directly by the interrupt handlers, because it requires a Lock.

"nBoxes" is the number of mail boxes in this Post Office

Definition at line 160 of file post.cc.

PostOfficeInput::~PostOfficeInput ( )
 

De-allocate Post Office data.

PostOfficeInput::~PostOfficeInput De-allocate the post office data structures.

Since the postal helper is waiting on the "messageAvail" semaphore, we don't deallocate it! This leaves garbage lying about, but the alternative is worse!

Definition at line 183 of file post.cc.


Member Function Documentation

void PostOfficeInput::CallBack ( ) [virtual]
 

Called when incoming packet has arrived and can be pulled off of network (i.e., time to call PostalDelivery).

PostOffice::CallBack Interrupt handler, called when a packet arrives from the network.

Signal the PostalDelivery routine that it is time to get to work!

Reimplemented from CallBackObj.

Definition at line 260 of file post.cc.

void PostOfficeInput::PostalDelivery ( )
 

Wait for incoming messages, and then put them in the correct mailbox.

PostOffice::PostalDelivery Wait for incoming messages, and put them in the right mailbox.

Incoming messages have had the PacketHeader stripped off, but the MailHeader is still tacked on the front of the data.

Definition at line 198 of file post.cc.

void PostOfficeInput::Receive ( int box,
PacketHeader * pktHdr,
MailHeader * mailHdr,
char * data )
 

Retrieve a message from "box". Wait if there is no message in the box.

PostOfficeInput::Receive Retrieve a message from a specific box if one is available, otherwise wait for a message to arrive in the box.

Note that the MailHeader + data looks just like normal payload data to the Network.

"box" -- mailbox ID in which to look for message

"pktHdr" -- address to put: source, destination machine ID's

"mailHdr" -- address to put: source, destination mailbox ID's

"data" -- address to put: payload message data

Definition at line 243 of file post.cc.

Referenced by NetKernel::SelfTest().


Member Data Documentation

MailBox * PostOfficeInput::boxes [private]
 

Table of mail boxes to hold incoming mail.

Definition at line 123 of file post.h.

Semaphore * PostOfficeInput::messageAvailable [private]
 

V'ed when message has arrived from network.

Definition at line 125 of file post.h.

NetworkInput * PostOfficeInput::network [private]
 

Physical network connection.

Definition at line 122 of file post.h.

int PostOfficeInput::numBoxes [private]
 

Number of mail boxes.

Definition at line 124 of file post.h.


The documentation for this class was generated from the following files:
Generated at Wed Jul 4 11:32:23 2001 for Nachos by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001