13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The kernel and processes 17For example, the CP/M operating system provides three levels: (1) device drivers (theBIOS section of the kernel), (2) a file manager (BDOS), and (3) an interactive commandinterpreter (CCP). It supports only one process and provides no security, so there is noneed for special context-switch services.Switching context from the kernel back to a process involves copying informationbetween the context block and hardware registers of the machine. This informationincludes the program counter, the processor state, and the contents of addressible registers.Most high-level languages (including Modula) do not provide the necessary facilityto deal with these hardware issues directly. Luckily, some newer computers (such as theDEC VAX) have single instructions that do all the context-switch work themselves. Still,high-level languages are unlikely to generate those instructions. Furthermore, the speedof context switching is critical because this operation takes place every time an interruptis serviced by the kernel or a process makes a request to the kernel. The result is thatcontext switching is usually performed by a procedure written in assembler language.5.2 Process listsThe context blocks for processes are stored in lists. Each list is dedicated to some particularclass of processes. These classes can be divided as follows.Running. The process that is currently executing. On most computers, only oneprocess is running at any time. However, on multiprocessors, which we discuss inChapter 9, several processes can run at once.Ready. Processes that are ready to run but are not currently running because of apolicy decision. As we will see in Chapter 2, there may be several ready lists.Waiting. Processes that cannot run now because they have made requests thathave not yet been fulfilled. The kernel might keep a different list for every type ofservice that may have been requested. For example, space management sometimescauses processes to wait in a ‘‘main-store wait’’ list until there is enough room torun them. A process reading data from a file might wait in a ‘‘file transput waitlist’’ until the data are read in. Each device that a process may use for transputmight have its own wait list. While a process is in a wait list, we say it is blocked.These lists are commonly called ‘‘queues,’’ but they need not be built as queues usuallyare, with entry only at one end and departure from the other. They may be representedimplicitly, with each context block holding a field that indicates which list it is on. Theymay be stored in a heap data structure according to some priority so that the one with themost urgency can be accessed quickly.5.3 Service calls

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!