for (;;) {
if (c1) a1();
if (c2) a2();
...
}
→ worst-case latency: sum of all actions - higher-frequency input/condition 'c1'
for (;;) {
if( c1 ) a1;
if( c2 ) a2;
if( c1 ) a1;
if( c3 ) a3;
...
}
→ worst-case latency: maximum of all actions - latency still too high? break up action into parts
for (;;) {
if( c1 ) a1;
if( c2 ) { a2.1; half-done = TRUE; }
if( c1 ) a1;
if( half-done ) { a2.2; half-done = FALSE; }
...
}
→ quicky gets complicated and no runtime flexibility
void kmain() {
initialize(); // includes starting the first user task
for (;;) {
currtask = schedule();
request = activate(currtask);
handle(request);
}
}