Mailbox

From Embedded Xinu
Revision as of 18:30, 2 August 2007 by Agember (talk | contribs) (Explanation of mailboxes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A mailbox is a messaging queue used for interprocess communication. Mailboxes should not to be confused with the single message capability built into the process control block which uses send and receive.

XINU allows for a finite number of mailboxes to be created. Each mailbox is identified by a number. Any number of processes can send and receive messages from the mailbox, provided the processes know the correct mailbox number.

When a new mailbox is created (allocated) a maximum number of messages allowed in the queue must be specified. Memory for the messages is allocated when the mailbox is created. Once the mailbox message queue is full, processes that attempt to send a message must wait for space in the queue. If the queue is empty, processes that attempt to receive a message must wait for a message to be enqueued. A message is 4 bytes long.

When a mailbox is deleted all remaining messages in the queue are destroyed. Processes waiting to send or receive are released from the wait state.