IXP1200 Network Processor Family ATM
4.5.2Usage Model
The following model is described by an analogy to waiting in line at a bakery:.
Step | Sequence Operation | Bakery Line Analogy | |
|
|
| |
| sequence_enter() returns a sequence number to a thread |
| |
1 | and updates the absolute.enter so that the next time | Enter bakery and take a ticket. | |
sequence_enter() is invoked, the following sequence | |||
|
| ||
| number will be returned |
| |
|
|
| |
2 | sequence_wait() compares its sequence number with the | Wait in line for the "Now Serving" sign to | |
absolute.exit, and context swaps until they are the same. | match your ticket. | ||
| |||
|
|
| |
3 | Having gotten past sequence_wait(), the thread | Get served, keep others in line away from | |
processes the critical region. | counter. | ||
| |||
|
|
| |
| sequence_exit() increments absolute.exit to let the next | Exit bakery, "Now Serving..." sign gets | |
4 | incremented to let next customer to | ||
sequence number past sequence_wait(). | |||
| counter. | ||
|
| ||
|
|
|
4.5.2.1Example
#define MY_SEQUENCE_HANDLE my_seq_number, @enter, @one, @exit, @one, 32 sequence_init(MY_SEQUENCE_HANDLE) // initilize global state
while()
<...> // get work in order
sequence_enter(MY_SEQUENCE_HANDLE) // record the order <...> // process
4.6Message Queues - msgq.uc
The Message Queue subsystem supports
If the sender sends to a full queue, it will return an error so that the sender is able to determine what to do with the unsent message.
The threads within the sender must cooperate and not simultaneously access the same queue. This is typically done by putting the msgq_send() or msgq_receive() inside a critical section.
The message queue handle can specify that receives be either asynchronous or synchronous:
•Asynchronous receives (MSGQ_ASYNC) will return after reading what was in the queue, no matter if it was valid or invalid. The invoking thread must look at the invalid bit to decide what to do with the message.
•Synchronous receives can either loop internally on receipt of invalid messages (MSGQ_SYNC_POLL), or go to sleep after receiving an invalid message (MSGQ_SYNC_SLEEP). The sender must know to (always) wake up the receiver if MSGQ_SYNC_SLEEP is used.
42 | Application Note |
Modified on: 3/20/02,