CH03 - Process_Description_and_Control
CH03 - Process_Description_and_Control
g Chapter 3
Systems:
Internals Process
and Description and
Design
Principles
Control
Eighth Edition
Global Edition
By William Stallings
Summary of Earlier
Concepts
A computer platform The OS was developed
consists of a collection to provide a
of hardware resources convenient, feature-
rich, secure, and
Computer applications consistent interface
are developed to for applications to use
perform some task
We can think of the
It is inefficient for OS as providing a
applications to be uniform, abstract
written directly for a
given hardware platform representation of
resources that can be
requested and
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
Theprocessor 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
program
state priority
counter
accountin
context I/O status
memory g
data informati
pointers informati
(data in registers) on
on
Process Control
Block (Simplified)
Contains the process
elements
Created and managed by
the operating system
It is possible to interrupt
a running process and
later resume execution as
if the interruption had not
occurred
Key tool that allows
support for multiple
Process & Processor
behavior
the behavior of an Dispatch
Trace
individual process er
by listing the
sequence of
instructions that small program
execute for that that switches the
process processor from
one process to
another
the behavior of the
processor can be
characterized by
showing how the
traces of the various
processes are
interleaved
Process
Execution
The same assume that the OS
sequence of only allows a
instructions is process to continue
executed by the execution for a
dispatcher in each maximum of six
instance because instruction cycles,
the same after which it is
functionality of the interrupted
dispatcher is
being executed
Two-State Process
Model
Table 3.1 Reasons for
Process Creation
Process Creation
Process Parent Child
spawning process process
• when the • is the • is the
OS original, new
creates a creating, process
process process
at the
explicit
request
of
another
Process Termination
There must be a means for a process to
indicate its completion
A batch job should include a HALT instruction
or an explicit OS service call for termination
For an interactive application, the action of the
user will indicate when the process is
completed (e.g. log off, quitting an
application)
Table3.
2Reasons
for
Process
Terminati
on
(Table is located on
page 145 in the
textbook)
Five-State Process
Model
Control block
is created for
the new
process 2-sate is not enough when:
Some processes in the Not
Running state are ready to
execute, while others are
blocked, waiting for an I/O
operation to complete
Fig 3.8:
Queuing
Model for Fig
3.6
Suspended
Processes
Swapping
Explained
in p.32
Memory Tables
Used to keep track of
both main (real) and
Must
secondary (virtual)
memory
include:
allocation of main
memory to processes
Processes are
maintained on allocation of secondary
secondary memory memory to processes
protection attributes of
using some sort of
blocks of main or virtual
virtual memory or memory
simple swapping information needed to
mechanism manage virtual memory
such as which processes may access
certain shared memory regions
I/O Tables
Used by the OS to
manage the I/O
devices and channels If an I/O operation is
of the computer in progress, the OS
system needs to know:
• the status of the I/O
At any given time, an operation
I/O device may be • the location in main
available or assigned memory being used as the
to a particular process source or destination of
the I/O transfer
File Tables
These tables provide
information about:
• existence of files
• location on secondary
memory
• current status
• other attributes
Information may be maintained and used by a file
management system
in which case the OS has little or no knowledge of
files
In other operating systems, much of the detail of file
management is managed by the OS itself
Process Tables
Mustbe maintained to manage
processes
There must be some reference to
memory, I/O, and files, directly or
indirectly
Thetables themselves must be
accessible by the OS and therefore are
subject to memory management
Process Control
Structures
To
manage • where the
and process is
located
control a • the attributes
process of the process
the OS that are
necessary for
must its
know: management
process ID, state,
priority, etc.
Process Control
Structures
Process Location Process Attributes
A process must include a Each process has
program or set of programs associated with it a number
to be executed of attributes that are used
A process will consist of at by the OS for process
least sufficient memory to control
hold the programs and data The collection of program,
of that process data, stack, and attributes
The execution of a program is referred to as the
typically involves a stack that process image
is used to keep track of Process image location
procedure calls and will depend on the memory
parameter passing between management scheme
procedures being used
Table 3.4
Typical Elements of a Process
Image
Table 3.5
Typical
Elements
of a
Process
Control
Block
(page 1 of 2)
(Table is located
on page 159 in the
textbook)
Table 3.5
Typical
Elements of
a Process
Control Block
(page 2 of 2)
(Table is located
on page 159 in the
textbook)
1. Process
Identification
Memory tables may be
Each process is assigned a organized to provide a map of
unique numeric identifier main memory with an indication
otherwise there must be of which process is assigned to
each region
a mapping that allows similar references will appear in
the OS to locate the I/O and file tables
appropriate tables based
on the process identifier When processes communicate
with one another, the process
Many of the tables identifier informs the OS of the
controlled by the OS may destination of a particular
communication
use process identifiers to
cross-reference process When processes are allowed to
tables create other processes,
identifiers indicate the parent
For example: memory
and descendents of each
tables process
2. Processor State
Information
• user- • contains
visible condition codes
Consists registers plus other
Progra status
of the • control information
contents m
of and status • EFLAGS register
processo
r
status word is an example
registers (PSW) of a PSW used
registers
by any OS
• stack A register or
running on an
a set of
pointers registers x86 processor
in Chapter 1
3. Process Control
Information
Theadditional information
needed by the OS to control
and coordinate the various
active processes
Process
image 1
the process control block may contain
structuring information, including
pointers that allow the linking of
process control blocks
Role of the
Process Control
Block
The most important data structure in an OS
contains all of the information about a process that is
needed by the OS
blocks are read and/or modified by virtually every
module in the OS
defines the state of the OS
Typical
Functions
of an
Operating
System
Kernel
Process Creation
Once the OS decides to create a new
process it:a unique process
assigns
identifier to the new process
Operating
System
Execution
Within
User Processes
used to manage
calls/returns while the
process is in kernel mode
Unix SVR4
Uses the model (Figure 3.15b) where most of the OS
executes within the environment of a user process
System processes run in kernel mode
executes operating system code to perform administrative
and housekeeping functions
User Processes
operate in user mode to execute user programs and utilities
operate in kernel mode to execute instructions that belong to
the kernel
enter kernel mode by issuing a system call, when an exception
is generated, or when an interrupt occurs
Table 3.9 UNIX Process
States
Table
3.10
UNIX
Proces
Image
(Table is located
on page 174 in
the textbook)
Table
3.11
UNIX
Process
Table
Entry