tendency to take longer than they should. Also, information for a background module made available by an ISR is not processed until the background routine gets its turn to execute. This is called the
task level response
. The worst casetask level response time depends on how long the background loop takes to execute. Because the execution time of typical code is not constant, the time for successive passes through a portion of the loop is non-deterministic.Furthermore, if a code change is made, the timing of the loop is affected.Most high volume microcontroller-based applications (e.g., microwave ovens, telephones, toys, and so on) aredesigned as foreground/background systems. Also, in microcontroller-based applications, it may be better (from a power consumption point of view) to halt the processor and perform all of the processing in ISRs.
Figure 2-1, Foreground/background systems
2.01 Critical Section of Code
A critical section of code, also called a
, is code that needs to be treated indivisibly. Once the section of code starts executing, it must not be interrupted. To ensure this, interrupts are typically disabled before the criticalcode is executed and enabled when the critical code is finished (see also Shared Resource).
A resource is any entity used by a task. A resource can thus be an I/O device such as a printer, a keyboard, a display,etc. or a variable, a structure, an array, etc.
2.03 Shared Resource
A shared resource is a resource that can be used by more than one task. Each task should gain exclusive access to theshared resource to prevent data corruption. This is called
and techniques to ensure mutual exclusionare discussed in section 2.19,