Modern operating systems have the ability to switch between processes. This is used in multiprogramming (also known as cooperative multitasking) and multitasking (or pre-emptive multitasking). The idea is that the CPU is currently concentrating on one process. But at some point, it needs to switch to another. To do so, it must save its register values (PC, IR, status flags, perhaps the AC and other registers) to memory and then restore the stored register values of another process before that process can be resumed (or started). The switching from one process to another is called a context switch.

This example comes from the textbook figure 4.4. What we see here is the CPU working its way through the fetch-execute cycle, executing process P3. At some point, P3 suspends itself (perhaps it has to wait for time consuming input). The operating system forces a context switch from process P3 to process P7. P7 is then resumed until it suspends itself, completes executing, or P3 becomes available again.


NOTE: to replay, right click and select Play