21.01.2015 Views

INtime® 3.1 Software - tenAsys

INtime® 3.1 Software - tenAsys

INtime® 3.1 Software - tenAsys

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3: About INtime software’s RT kernel<br />

Mailboxes<br />

Mailboxes provide communication between threads in the same process or in different<br />

processes. They can send information and, since a thread may have to wait for<br />

information before executing, they can synchronize thread execution. There are two<br />

mailbox types:<br />

• Object mailboxes: Send and receive object handles. Available only as high<br />

level objects.<br />

• Data mailboxes: Send and receive data. Available as both high- and low-level<br />

objects. High-level data mailboxes have a maximum message size of 128 bytes.<br />

The next figure shows how threads use an object mailbox to send a handle for a<br />

memory address.<br />

Figure 3-2. Threads using an object mailbox<br />

A<br />

<br />

<br />

B<br />

<br />

<br />

Thread A allocates a block of memory and creates a shared-memory handle for it. Data is placed<br />

in this shared memory object.<br />

Thread A sends the shared memory handle to a mailbox.<br />

Thread B waits to receive the shared memory handle at the mailbox. You can specify whether<br />

thread B should wait if the handle isn’t in the mailbox.<br />

Thread B obtains the handle and accesses the data in the memory object by mapping the<br />

memory associated with the memory object into its memory address space.<br />

Mailboxes have thread queues, where threads wait for messages, and message queues,<br />

where messages wait threads to receive them. The thread queue may be FIFO- or<br />

priority-based; the message queue is always FIFO-based.<br />

You use the same system calls to create and delete object and data mailboxes. However,<br />

you use different calls to send and receive messages or data.<br />

35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!