Embedded Xinu Operating System
An ongoing research project and educational operating system.
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
Functions
Mailboxes

Xinu's mailbox subsystem allows threads to send and receive messages to each other. More...

Functions

syscall mailboxAlloc (uint count)
 
syscall mailboxCount (mailbox box)
 
syscall mailboxFree (mailbox box)
 
syscall mailboxInit (void)
 
syscall mailboxReceive (mailbox box)
 
syscall mailboxSend (mailbox box, int mailmsg)
 

Detailed Description

Xinu's mailbox subsystem allows threads to send and receive messages to each other.

Function Documentation

syscall mailboxAlloc ( uint  count)

Allocate a mailbox that allows up to the specified number of outstanding messages.

Parameters
countMaximum number of messages allowed for the mailbox.
Returns
The index of the newly allocated mailbox, or ::SYSERR if all mailboxes are already in use or other resources could not be allocated.
syscall mailboxCount ( mailbox  box)

Retrieve the number of outstanding messages in the specified mailbox.

Parameters
boxThe index of the mailbox for which to retrieve the number of outstanding messages.
Returns
The number of messages in the mailbox, or ::SYSERR if box did not specify a valid allocated mailbox.
syscall mailboxFree ( mailbox  box)

Free the specified mailbox.

Parameters
boxThe index of the mailbox to free.
Returns
::OK if the mailbox was successfully freed, or ::SYSERR if box did not specify a valid allocated mailbox.
syscall mailboxInit ( void  )

Initialize mailbox structures.

Returns
::OK if all mailboxes were initialized successfully, otherwise ::SYSERR.
syscall mailboxReceive ( mailbox  box)

Receive a message from the specified mailbox.

Parameters
boxThe index of the mailbox to receive the message from.
Returns
On success, returns the message that was dequeued; on failure (box did not specify an allocated mailbox, or the mailbox was freed while waiting for a message) returns ::SYSERR. Note that it may be impossible to disambiguate ::SYSERR from a successful return value.
syscall mailboxSend ( mailbox  box,
int  mailmsg 
)

Send a message to the specified mailbox.

Parameters
boxThe index of the mailbox to send the message to.
mailmsgThe message to send.
Returns
::OK if the message was successfully enqueued, otherwise ::SYSERR. ::SYSERR is returned only if box did not specify a valid allocated mailbox or if the mailbox was freed while waiting for room in the queue.