IXP1200 Network Processor Family ATM OC-3/12/Ethernet IP Router Example Design

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 non-critical section sequence_wait(MY_SEQUENCE_HANDLE) // wait my turn msgq_send() // process critical section sequence_exit(MY_SEQUENCE_HANDLE) // let the next guy go

4.6Message Queues - msgq.uc

The Message Queue subsystem supports 31-bit messages between microengines. The queues are implemented with circular buffers, typically in scratchpad RAM. The queues are point-to-point, there can be only one sender microengine, and one receiver microengine because the queue indexes are stored privately in microengine registers rather than shared in RAM.

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,

Page 42
Image 42
Intel IXP1200 manual Message Queues msgq.uc, Usage Model, Example, Step Sequence Operation Bakery Line Analogy