Professional Documents
Culture Documents
Machine is
Powered up
Initialization
Load the kernel
Service an interrupt
H
a
r
d
w
a
r
e
p
r
o
c
e
s
s
p
r
o
g
r
e
s
s
Execute a thread
Schedule
The hardware process represents the sequence of machine instructions
executed by CPU
Slide 6-20
Copyri ght 2004 Pearson Educati on, Inc.
Operating Systems: A Modern Perspective, Chapter 6
Process Manager
Slide 6-21
Copyri ght 2004 Pearson Educati on, Inc.
The Abstract Machine Interface
Abstract machine interface has 2 kinds of
instruction :
1. User mode hardware instructions
2. OS functions
To make sure that when a process executes an
abstract machine instruction that is
implemented by an OS function, the system
intercepts the hardware execution and calls an
OS function instead.
Slide 6-22
Copyri ght 2004 Pearson Educati on, Inc.
The Abstract Machine Interface
The complete abstract machine interface is defined by the set of instructions
that the hardware can execute when the processor is in user mode.
The trap trap instruction instruction extends the
abstract machine interface so that the
abstract machine instructions include
all thefunctions ontheOS systemcall
interface.
Slide 6-23
Copyri ght 2004 Pearson Educati on, Inc.
The Process Abstraction
The process manager creates the environment in which
multiple processes coexists; each with its own abstract
machine.
When hardware process begins to execute OS code, it will
execute an algorithm that switches the hardware process
from one context (abstract machine) to another.
Context switches Context switches occur whenever the OS gets control of
the processor
whenever a process/thread makes a system call
(execute trap instruction)
whenever device interrupts occur
Slide 6-24
Copyri ght 2004 Pearson Educati on, Inc.
Context Switching
A context switch is the action taken by the hardware process when it
suspends execution on one program and begin execution on another.
Hardware process Hardware process Hardware process Hardware process Context Switching Context Switching Context Switching Context Switching
Slide 6-25
Copyri ght 2004 Pearson Educati on, Inc.
Operating Systems: A Modern Perspective, Chapter 6
Context switching
Slide 6-26
Copyri ght 2004 Pearson Educati on, Inc.
Operating Systems: A Modern Perspective, Chapter 6
Context Switch
Context switching
the action taken by the hardware process
when it suspends execution on one program
and begins execution on another.
Slide 6-27
Copyri ght 2004 Pearson Educati on, Inc.
Process Descriptor
OS creates/manages process abstraction
When a process is created, the process manager
algorithm creates a data structure called the process process
descriptor descriptor
to keep all details for managing the process.
Register values
Logical state
Type & location of resources it holds
List of resources it needs
Security keys
The process descriptor will de-allocated when the
process terminates
Slide 6-28
Copyri ght 2004 Pearson Educati on, Inc.
The Thread Abstraction
The thread management algorithm is the part of the
process manager that creates and manages threads.
The major task in managing a thread are :
Create / destroy a thread
Allocate thread-specific resources
Manage thread context switching and scheduling
Process manager contains algorithm to accomplish
these tasks as well as a central thread descriptor thread descriptor data
structure
Slide 6-29
Copyri ght 2004 Pearson Educati on, Inc.
The Thread Abstraction
The thread descriptor thread descriptor is the data structure where the OS will
keep all information it needs to manage that thread.
The fields that are incorporated into a generic thread
descriptor:
State
Execution statistics
Process
List of related threads
Stack
Other resources
Slide 6-30
Copyri ght 2004 Pearson Educati on, Inc.
State Diagram
After a process/thread has been created, OS has
descriptors that it can use to keep track of the
process/thread.
The OS will need to know in which linked list a
process is stored if it is to move the process.
In process managers, use a state state variable as a
summary status of the process/thread.
The state variable summarizes the process/thread
status by individual values.
Slide 6-31
Copyri ght 2004 Pearson Educati on, Inc.
State Diagram
A state diagram state diagram represents the different states in which
a thread can be at different times, along with the
transitions transitions from one state to another that are possible in
the OS.
The process manager causes the process/thread to
change state by administering the process.
Slide 6-32
Copyri ght 2004 Pearson Educati on, Inc.
Process State
The most basic process/thread diagram has three states : running, ready,
blocked.
Running : using the processor
Ready : wait for the processor
Blocked : a blocked process was running but request for resource that
unavailable. It will remain blocked until it is allocated the resource.
Slide 6-33
Copyri ght 2004 Pearson Educati on, Inc.
Operating Systems: A Modern Perspective, Chapter 6
Process State
Slide 6-34
Copyri ght 2004 Pearson Educati on, Inc.
Resource Manager
The generic part of resource manager is a mechanism mechanism
for allocating resources
The resource-specific behaviour is determined by a
policy policy
Every resource manager accepts requests accepts requests to allocate
units of its resource to a process as OS functions (the
request() request() function)
The request() request() function will execute a resource-
specific policy algorithm to determine the criteria under
which it should allocate resources to processes
Slide 6-35
Copyri ght 2004 Pearson Educati on, Inc.
Resource Manager
The behavior of a resource manager using formal
model:
There are many, m, different types of resources
Each type can have multiple units
Processes can requestvariable numbers of units of
the resource
At any given moment, some number of units of each
of the resource type are available, hence it would be
allocated
Slide 6-36
Copyri ght 2004 Pearson Educati on, Inc.
Operating Systems: A Modern Perspective, Chapter 6
Using the Model
There is a resource manager, Mgr(R
j
) for every R
j
Mgr(R
j
)
Process Process
p
i
can only request n
i
c
j
units of reusable R
j
p
i
can request unbounded #of units of consumable R
j
Process p
i
can request units of R
j
if it is currently running
request
Mgr(R
j
) can allocate units of R
j
to p
i
allocate
Slide 6-37
Copyri ght 2004 Pearson Educati on, Inc.
Resource Manager
Process Process
Resource Manager
Process Process
Process Process
Process Process
Blocked Processes
Resource Pool
r equest ( )
r el ease( )
Policy
Await allocation of
resource
Slide 6-38
Copyri ght 2004 Pearson Educati on, Inc.
Resource Manager
Resource desriptor Resource desriptor:
Internal resource name
Total units
Available units
List of available units
List of blocked processes
Slide 6-39
Copyri ght 2004 Pearson Educati on, Inc.
Resource Manager
CPU,
primary
memory,
disk space
Message,
input data
Slide 6-40
Copyri ght 2004 Pearson Educati on, Inc.
Operating Systems: A Modern Perspective, Chapter 6
Process Manager Overview
Program
Process
Abstract Computing Environment
File
Manager
Memory
Manager
Device
Manager
Protection
Deadlock
Synchronization
Description
Process
Description
CPU Other H/W
Scheduler
Resource
Manager
Resource
Manager
Resource
Manager
Memory Devices