Hardware Reference
In-Depth Information
Process 3 waiting for CPU
Process 3
Process 3
Process 2
Process 2
Process 1
Process 1
Process 1 running
Time
Time
(a)
(b)
Figure 6-24. (a) True parallel processing with multiple CPUs. (b) Parallel proc-
essing simulated by switching one CPU among three processes.
6.4.1 Process Creation
When a program is to be executed, it must run as part of some process. This
process, like all others, is characterized by a state and an address space through
which the program and data can be accessed. The state includes at the very least
the program counter, a program status word, a stack pointer, and the general regis-
ters.
Most modern operating systems allow processes to be created and terminated
dynamically. To take full advantage of this feature to achieve parallel processing, a
system call to create a new process is needed. This system call may just make a
clone of the called, or it may allow the creating process to specify the initial state
of the new process, including its program, data, and starting address.
In some cases, the creating (parent) process maintains partial or even complete
control over the created (child) process. To this end, virtual instructions exist for a
parent to stop, restart, examine, and terminate its children. In other cases, a parent
has less control over its children: once a process has been created, there is no way
for the parent to forcibly stop, restart, examine, or terminate it. The two processes
then run independently of one another.
6.4.2 Race Conditions
In many cases, parallel processes need to communicate and synchronize in
order to get their work done. In this section, process synchronization will be ex-
amined and some of the difficulties explained by means of a detailed example. A
solution to these difficulties will be given in the following section.
 
 
 
Search WWH ::




Custom Search