
122 Chapter 8: Operating Systems
Of course, if interrupts are ever disabled within the operating system, the worst-
case interrupt latency increases by the maximum amount of time that they are
turned off. But as we have just seen, there are many places where interrupts are
disabled. These are the critical sections we talked about earlier, and there are no
alternative methods for protecting them. Each operating system will disable inter-
rupts for a different length of time, so it is important that you know what your sys-
tem’s requirements are. One real-time project might require a guaranteed interrupt
response time as short as 1 µs, while another requires only 100 µs.
The third real-time characteristic of an operating system is the amount of time
required to perform a context switch. This is important because it represents over-
head across your entire system. For example, imagine that the average execution
time of any task before it blocks is 100 µs but that the context switch time is also
100 µs. In that case, fully one-half of the processor’s time is spent within the con-
text switch routine! Again, there is no magic number and the actual times are usu-
ally processor-specific because they are dependent on the number of registers that
must be saved and where. Be sure to get these numbers from any operating sys-
tem vendor you are thinking of using. That way, there won’t be any last-minute ...