Professional Documents
Culture Documents
Process Description & Control
Process Description & Control
Process Description
and Control
Summary of Earlier
Concepts
A computer platform The OS was developed to
consists of a collection of provide a convenient,
hardware resources feature-rich, secure, and
consistent interface for
Computer applications applications to use
are developed to perform
some task We can think of the OS as
providing a uniform,
abstract representation of
It is inefficient for resources that can be
applications to be written requested and accessed by
directly for a given
hardware platform applications
OS Management of
Application Execution
Resources are made available to multiple
applications
Theprocessor is switched among multiple
applications so all will appear to be
progressing
The processor and I/O devices can be used
efficiently
Process Elements
Two essential elements of a process are:
Program code
which may be shared with other processes that are executing the
same program
identifier
program
state priority
counter
• Memory pointers: Includes pointers to the program code and data associated
with this process, plus any memory blocks shared with other processes.
• Context data: These are data that are present in registers in the processor
while the process is executing.
• I/O status information: Includes outstanding I/O requests, I/O devices (e.g.,
disk drives) assigned to this process, a list of files in use by the process, and
so on.
• Accounting information: May include the amount of processor time and clock
time used, time limits, account numbers, and so on.
Process Control Identifier P
State
s
Block Priority
Program counter
i
Memory pointers
r
Contains the process elements Context data b
I/O status c
It is possible to interrupt a running information
p
process and later resume execution as if
the interruption had not occurred
Accounting
information I
m
Created and managed by the operating s
system
d
Key tool that allows support for d
multiple processes o
Figure 3.1 Simplified Process Control Block
Process States
Trace Dispatcher
the behavior of an
individual process
by listing the
sequence of small program
instructions that that switches the
execute for that processor from
process one process to
another
Process 5000
Process A
Execution 8000
Process B
12000
Process C
Dispatch
Pause
Queue
Enter Dispatch Exit
Processor
Pause
Pause
Queue
Enter Dispatch Exit
Processor
Pause
Table 3.2 Time limit exceeded The process has run longer than the specified total time limit. There are a
number of possibilities for the type of time that is measured. These include total
elapsed time ("wall clock time"), amount of time spent executing, and, in the
case of an interactive process, the amount of time since the user last provided
any input.
Reasons for Memory unavailable The process requires more memory than the system can provide.
Protection error
The process tries to access a memory location that it is not allowed to access.
The process attempts to use a resource such as a file that it is not allowed to use,
Time overrun The process has waited longer than a specified maximum for a certain event to
occur.
I/O failure An error occurs during input or output, such as inability to find a file, failure to
read or write after a specified maximum number of tries (when, for example, a
defective area is encountered on a tape), or invalid operation (such as reading
from the line printer).
Invalid instruction The process attempts to execute a nonexistent instruction (often a result of
branching into a data area and attempting to execute the data).
Privileged instruction The process attempts to use an instruction reserved for the operating system.
Operator or OS intervention For some reason, the operator or the operating system has terminated the process
(e.g., if a deadlock exists).
Parent termination When a parent terminates, the operating system may automatically terminate all
of the offspring of that parent.
(Table is located on page 115 Parent request A parent process typically has the authority to terminate any of its offspring.
in the textbook)
Five-State Process Model
Dispatch
Admit Release
New Ready Running Exit
Timeout
Event
Occurs Event
Wait
Blocked
Process B
Process C
Dispatcher
0 5 10 15 20 25 30 35 40 45 50
Timeout
Blocked Queue
Event Event Wait
Occurs
(a) Single blocked queue
Timeout
Event 1 Queue
Event 1 Event 1 Wait
Occurs
Event 2 Queue
Event 2 Event 2 Wait
Occurs
Event n Queue
Event n Event n Wait
Occurs
Occurs
Event
Suspend
Suspend Blocked
New
Activate Dispatch
Ready/ Release
Suspend Ready Running Exit
Suspend Timeout
Occurs
Occurs
Event
Event
Activate
Blocked/
Suspend
Blocked
Suspend
Ad mi t Di s patc h
R eleas e
New Re ady Ru nn in g E xit
Ti me out
Ocurs
Event
Su spe nd
S uspe nd B l ock ed
Ne w
Ocurs
Event
Event
A cti vate
B loc ke d /
B l ock ed
Su sp e n d
S usp end
(b ) Wi th T wo S u sp en d Stat es
Occurs
Event
Suspend
Suspend Blocked
New
Activate Dispatch
Ready/ Release
Suspend Ready Running Exit
Suspend Timeout
Occurs
Occurs
Event
Event
Activate
Blocked/
Suspend
Blocked
Suspend
Computer
Resources
Main
Processor I/O I/O I/O
Memory
Figure 3.10 Processes and Resources (resource allocation at one snapshot in time)
Process
Image
Memory Tables
Process
Memory 1
Files
Process 1
Process 2
Process
Process 3 Image
Process
n
Process n
To manage
• where the
and process is located
control a • the attributes of
process the process that
the OS are necessary for
its management
must
know:
Process Control Structures
Process Location Process Attributes
A process must include a program Each process has associated with
or set of programs to be executed it a number of attributes that are
used by the OS for process control
A process will consist of at least
sufficient memory to hold the The collection of program, data,
programs and data of that process stack, and attributes is referred to
as the process image
The execution of a program
typically involves a stack that is Process image location will
used to keep track of procedure depend on the memory
calls and parameter passing management scheme being used
between procedures
Table 3.4
Typical Elements of a Process Image
User Data
The modifiable part of the user space. May include program data, a user stack area, and
programs that may be modified.
User Program
The program to be executed.
Stack
Each process has one or more last-in-first-out (LIFO) stacks associated with it. A stack is
used to store parameters and calling addresses for procedure and system calls.
Stack Pointers
Each process has one or more last-in-first-out (LIFO) system stacks associated with it. A stack is used
to store parameters and calling addresses for procedure and system calls. The stack pointer points to
(Table is located
the top of the stack. on page 129 in the
textbook)
Process Control Information
Memory Management
This section may include pointers to segment and/or page tables that describe the virtual memory
assigned to this process.
• user-visible
• contains condition
Consists registers codes plus other
of the
contents
• control and Progra status information
of status m status • EFLAGS register is
processo word an example of a
r
registers (PSW) PSW used by any
registers • stack OS running on an
x86 processor
pointers
Process Control
Information
The additional information needed
by the OS to control and
coordinate the various active
processes
Process Process Process
Identification Identification Identification
Process
Processor State Processor State Processor State Control
Information Information Information Block
Process Control Process Control Process Control
Information Information Information
Ready
Blocked
Support Functions
•Interrupt handling
•Accounting
•Monitoring
Process Creation
Once the OS decides to create a new process it:
assigns a unique process identifier to the
new process
Execution
Kernel
of the P1
OS
Func-
P2
OS
Func-
Pn
OS
Func-
Operating System
tions tions tions
P1 P2 Pn OS1 OSk
Execution Within
Information Block
Process Control
Information
Private User
Address Space
(Programs, Data)
Kernel Stack
Shared Address
Space