03.08.2013 Views

Design and Implementation of TinyGALS: A Programming Model for ...

Design and Implementation of TinyGALS: A Programming Model for ...

Design and Implementation of TinyGALS: A Programming Model for ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>and</strong> pulls packets from its input. Click is a pure polling system; the device never interrupts<br />

the processor.<br />

Timers are another way <strong>of</strong> activating an element besides tasks. An element can have any<br />

number <strong>of</strong> active timers, where each timer calls an arbitrary method when it fires. Timers<br />

are implemented using Linux timer queues.<br />

FromDevice<br />

receive<br />

packet p<br />

Null Null ToDevice<br />

enqueue p<br />

dequeue p<br />

<strong>and</strong> return it<br />

ready to<br />

transmit<br />

send p<br />

push(p) push(p)<br />

return<br />

return<br />

pull()<br />

pull()<br />

return p return p<br />

Figure 22: A simple Click configuration with sequence diagram.<br />

Figure 22 shows a simple Click router configuration with a push chain (FromDevice<br />

<strong>and</strong> Null) <strong>and</strong> a pull chain (Null <strong>and</strong> ToDevice). The two chains are separated by a Queue<br />

element. The Null element simply passes a packet from its input port to its output port;<br />

it per<strong>for</strong>ms no processing on the packet. Note that in the sequence diagram in Figure 22,<br />

time moves downwards. Control flow moves <strong>for</strong>ward during a push sequence, <strong>and</strong> moves<br />

backward during a pull sequence. Data flow (in this case, the packet p) always moves<br />

<strong>for</strong>wards.<br />

Figure 23 illustrates the basic execution sequence <strong>of</strong> Figure 22. When the task corre-<br />

sponding to FromDevice is activated, the element polls the receive DMA ring <strong>for</strong> a packet.<br />

FromDevice calls push() on its output port, which calls the push() method <strong>of</strong> Null. The<br />

push() method <strong>of</strong> Null calls push() on its output port, which calls the push() method<br />

<strong>of</strong> the Queue. The Queue element enqueues the packet if its queue is not full; otherwise<br />

it drops the packet. The calls to push() then return in the reverse order. Later, the task<br />

corresponding to ToDevice is activated. If there is an empty slot in its transmit DMA ring,<br />

ToDevice calls pull() on its input port, which calls the pull() method <strong>of</strong> Null. The<br />

49

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

Saved successfully!

Ooh no, something went wrong!