CH 3
CH 3
CH 3
Operating Systems
Lecture 3:
Process management
Introduction
Process Concept
Early computer systems allowed only one program to
concurrently.
5
The Process
a process is a program in execution. A process is more
than the program code, which is sometimes known as the
text section. It also includes the current activity, as
represented by the value of the program counter and the
contents of the processor's registers. A process generally also
includes the process stack, which contains temporary data,
and a data section, which contains global variables. A process
may also include a heap. The structure of a process in
memory is shown in Figure 3.1.
7
Process in Memory
8
Process State
As a process executes, it changes state. The state of a process
is defined in part by the current activity of that process. Each
process may be in one of the following states:
New. The process is being created.
Running. Instructions are being executed.
Waiting. The process is waiting for some event to occur.
Ready. The process is waiting to be assigned to a
processor.
Terminated. The process ha finished execution.
10
including these:
12
Process scheduling …
more processes, the rest will have to wait until the CPU is
Scheduling Queues
queue.
17
Since there are many processes in the system, the disk may
process therefore may have to wait for the disk. The list of
ready queue.
23
the waiting state to the ready state and is then put back in the
Scheduler
appropriate scheduler.
25
swapped in..
30
Context Switch
interrupts cause the operating system to change a CPU from
includes the value of the CPU registers, the process state, and
Switch.
33
Operations on processes
termination.
34
Process Creation
init
pid = 1
emacs tcsch
ps
pid = 9204 pid = 4005
pid = 9298
37
terms of execution:
2. The parent waits until some or all of its children have terminated.
1. The child process is a duplicate of the parent process (it has the same
Process Termination
A process terminates when it finishes executing its final
process (via the wait() system call). All the resources of the
Communications Models
(a) Message passing. (b) shared memory.
44
Shared-Memory Systems
Normally, the operating system tries to prevent one process
from accessing another process's memory. Shared memory
requires that two or more processes agree to remove this
restriction. They can then exchange information by
reading and writing data in the shared areas. The form of the
data and the location are determined by these processes and
are not under the operating system's control. The processes
are also responsible for ensuring that they are not writing
to the same location simultaneously.
45
Message-Passing Systems
Message passing provides a mechanism to allow processes to
communicate and to synchronize their actions without
sharing the same address space and is particularly
useful in a distributed environment, where the
communicating processes may reside on different computers
connected by a network. For example, a chat program
used on the World Wide Web could be designed so that chat
participants communicate with one another by exchanging
messages.
46
• Sockets
• Remote Procedure Calls
• Pipes
• Remote Method Invocation
(Java)