Response to stimuli is instantaneous, because it drives scheduling at a primitive level. CPU, interrupt, and DMA resources are used with complete efficiency, as soon as needed and available. I will sketch a pseudocode sample here in occam, which has a syntax similar to C but uses indentation, like Python.
CHAN OF ANY kbdHard: -- interrupt-driven hardware channel CHAN OF ANY kbdSoft: -- cooked characters CHAN OF ANY mathAssign: -- pass tasks to compute process CHAN OF ANY mathDone: -- receive responses back CHAN OF ANY screenSoft: -- output intended for display PAR -- input output keyboard(kbdHard, kbdSoft) -- input output input output organizer(kbdSoft, mathAssign, mathDone, screenSoft) -- input output compute(mathAssign, mathDone) -- input screen(screenSoft)
Each process in this case is fully sequential, and the channels operate only in the directions shown. An output channel for screen is not shown, because screen hardware typically operates by evanescent mapped memory.
PROC compute(CHAN OF ANY assign, done) BOOL notDone: SEQ notDone := TRUE WHILE notDone SEQ assign ? nextRequest IF nextRequest = TERMINATE notDone := FALSE TRUE -- like a C "else" SEQ -- cpu intensive computation here done ! result :
This is the form of a simple worker, stimulated by one kind of input, AND it is also the form of a simple driver (the keyboard and screen processes would take the same form, except the screen process would manipulate mapped memory, not an output channel). Notice that sequential execution (the SEQ, like a C curly bracket) must be explicitly specified, like parallel execution (PAR).
The communication primitives are "?" for input and "!" for output. Notice that they can be used to split an assignment across two processes.
The most interesting setup, the one that makes completely general components possible, is the one for the organizer process, which has multiple stimuli. Here a select primitive, ALT, decides which one is heard first: others wait in line, as all communications block until acknowledged.
PROC organizer(CHAN OF ANY kbd, assign, done, screen) BOOL notDone: BOOL wasKbd: SEQ notDone := TRUE WHILE notDone SEQ ALT kbd ? nextKey wasKbd := TRUE done ? nextResult wasKbd := FALSE -- Proceed based on which kind of stimulus was just received. -- Branches will include output to "assign" if a math task is -- ready to be assigned, and to "screen" if something is ready -- to display. :
These processes can all be separately compiled, as they do not share undeclared globals. They can each be run on separate pieces of hardware, if desired. These must be connected by wires which realize the channels that were declared in the top block. Alternatively, some or all of them can share hardware, using software channels and multitasking CPU scheduling.