|CS 321 Spring 2013 > Lecture Notes for Friday, February 1, 2013|
An OS kernel keeps track of all processes. We call the structure in which process information is stored, the process table. Each entry is a process control block. This contains all information needed to move a process into a running state.
Such a movement is called a context switch. The old process’s information is stored in its control block, the new process’s information is read from its control block, the registers are set up, and execution of the new process resumes (or begins).
In Linux, the process table is a doubly linked list.
Each entry is of type
This stucture might vary a bit between kernel releases,
but it contains roughly the following data:
We noted that running multiple processes concurrently can reduce processor idle time—thus increasing efficiency—as compared to running only a single process. This happens because one process can be running while another is blocked. See the text for a more thorough analysis.
Note: This is not in the text.
When a computer is performing some task, the code executes in some context: local variables, address space, the executable being run, hardware, etc.
Different pieces of code might share a great deal of context, or very little. We consider some of the possibilities, ordered from most context shared to least.
We typically use the term coroutine when the implementation is at the language level. The idea is generally that two (or more) functions are currently active and communicating via some channel. Which function is actually being executed goes back and forth as necessary, in order to handle information passing through the channel. Support for coroutines is becoming increasingly common in modern programming languages. For example, the programming language Go includes coroutines in the form of the cutesily named “goroutines”. The Python programming language includes limited coroutine support in the form of “generators”.
We talk about user-level threads when these are managed at a somewhat lower level, and they are presented to the application programmer as running concurrently.
for an example of the use of coroutines
in the Python programming language.
(Kernel) threads will be our topic for the next few days.
Threads will be continued next time.