Polling loops allow you to manage more than one condition/activity pair at the same time.
The basic polling loop
FOREVER { if( c1 ) a1; if( c2 ) a2; ... if( cN ) aN; }
if( c<n>
) + execution time
of a<n>
Suppose you want a better response time for a1. Then try the loop
FOREVER { if( c1 ) a1; if( c2 ) a2; if( c1 ) a1; if( c3 ) a3; ... if( c1 ) a1; if( cN ) aN; }
Worst case response time for a1
if( c1 )
+ \max_n execution time for
if( cn ) an
Suppose the response time is still too long, because the execution of one action, say a2, is too long. Then you can break a2 into two parts
FOREVER { if( c1 ) a1; if( c2 ) { a2.1; half-done = TRUE } if( c1 ) a1; if( half-done ) a2.2; ... }
This is strarting to get a little complicated and we haven't said anything about inter-action communication
We can use interrupts to get rid of polling
Like function calls without arguments or return values.
Contrast RT to non-RT
Communication protocol existing since forever.
Why do we still use it in the age of USB, etc.
Three wires
Wired like this
GND ---------- GND XMIT --\ /---- XMIT X RCV----/ \---- RCV
What could be simpler?
Distinguish Data Terminal Equipment (DTE) from Data Circuit-terminating Equipment (DCE)
On the DE-9 connector we have for DTE
5 -- GND 3 -- XMIT 2 -- RCV
and for DCE
5 -- GND 3 -- RCV 2 -- XMIT
A very simple `straight through' cable connects these perfectly. But when we conect DTE to DTE we need the cable above, which is called a `null modem'.
Three wire works fine as long as both ends of the wire are much faster than the wire itself. But the train controller is very slow. Why?
The train controller needs to be able to say STOP. How is this done?
Return to: