| CS 321 Spring 2012 > Lecture Notes for Monday, January 30, 2012 |
Note: Since we are following the text more closely now, lecture notes will be limited to short summaries, along with material that is not in the text.
A process is a program in execution. A program is just code; a process is active. A single program may correspond to more than one process.
Processes allow for support of concurrency, also called multitasking: logically (if not actually) performing multiple tasks at once. This is in contrast to parallelism, in which we physically perform multiple tasks at once: this requires hardware support.
The OS is responsible for process scheduling.
In *ix OSs, new processes are created using fork.
This is supposed to copy all data of the parent process,
which can be slow.
One solution: vfork, a system call which does
not make the copy.
The idea is that the new process will do an execve
very soon.
The vfork call is unfortunately somewhat unsafe,
as modification of data between vfork and
a subsequent execve results in undefined behavior.
A more modern solution is to use copy-on-write.
The parent’s data is not copied immediately.
Part of the implementation of the fork
system call
is that the parent’s data is marked so that the
memory manager will
copy any data that is modified between a fork
and a subsequence execve.
Typically, very little is modified, which makes this
technique very efficient indeed.
On the other hand, if data do get modified,
then copy-on-write means that program behavior is still correct.
Under Windows,
a process is created using the CreateProcess
system call, discussed earlier.
This specifies the executable for the new process,
and so it is roughly equivalent to a fork-exec combination
under *ix OSs.
Processes can be terminated voluntarily or involuntarily, and due to an error or not. This means we have 4 different classes of methods for terminating processes. Examples of each are shown below.
| No Error | Error | |
|---|---|---|
| Voluntary | _exit(0) |
Uncaught exception |
| Involuntary | Killed by other process | Fatal error
E.g., segmentation fault due to unauthorized memory access |
Introduction to Processes will be continued next time.
ggchappell@alaska.edu