CS 537 Notes, Section #3: Dispatching, Creating Processes


Chapter 3, Sections 3.2 and 3.3 in Operating Systems Concepts.

How does dispatcher decide which process to run next?


Dispatcher Figure

CPU can only be doing one thing at a time: if user process is executing, dispatcher is not: OS has lost control. How does OS regain control of processor?

Internal events (things occurring within user process):

These are also called traps. They all cause a state switch into the OS.

External events (things occurring outside the control of the user process):

External events are usually called interrupts. They all cause a state switch into the OS. This means that user processes cannot directly take I/O interrupts.


When process is not running, its state must be saved in its process control block. What gets saved? Everything that next process could trash:


PCB Closeup Figure

How do we switch contexts between the user and OS? Must be careful not to mess up process state while saving and restoring it.

Saving state: it is tricky because the the OS needs some state to execute the state saving and restoring code.

Short cuts: as process state becomes larger and larger, saving and restoring becomes more and more expensive. Cannot afford to do full save/restore for every little interrupt.


Creating a process from scratch (e.g., the Windows/NT CreateProcess()):

Forking: want to make a copy of existing process (e.g., Unix).

What is missing?


Fork Figure



Copyright © 2001, 2002, 2008 Barton P. Miller
Non-University of Wisconsin students and teachers are welcome to print these notes their personal use. Further reproduction requires permission of the author.