Lect 3
Lect 3
Process
Description CHAPTER 3
and Control
2
Process
A program in execution
Dispatcher
5000
Process A
12000
Prevents a single process
from monopolizing
Process C processor time
1 5000 27 12004
5000 8000 12000 2 5001 28 12005
5001 8001 12001 3 5002 -------------------- Timeout
4 5003 29 100
5002 8002 12002 5 5004 30 101
5003 8003 12003 6 5005 31 102
5004 12004 -------------------- Timeout 32 103
7 100 33 104
5005 12005 8 101 34 105
5006 12006 9 102 35 5006
5007 12007 10 103 36 5007
11 104 37 5008
5008 12008 12 105 38 5009
5009 12009 13 8000 39 5010
5010 12010 14 8001 40 5011
15 8002 -------------------- Timeout
5011 12011 16 8003 41 100
(a) Trace of Process A (b) Trace of Process B (c) Trace of Process C ----------------I/O Request 42 101
17 100 43 102
5000 = Starting address of program of Process A 18 101 44 103
19 102 45 104
8000 = Starting address of program of Process B 20 103 46 105
12000 = Starting address of program of Process C 21 104 47 12006
22 105 48 12007
23 12000 49 12008
24 12001 50 12009
25 12002 51 12010
Figure 3.3 Traces of Processes of Figure 3.2 26 12003 52 12011
-------------------- Timeout
Process A
Process B
Process C
Dispatcher
0 5 10 15 20 25 30 35 40 45 50
Dispatch
Admit Release
New Ready Running Exit
Timeout
Event
Occurs Event
Wait
Blocked
Event
at
tW
iv
ct
en
A
Ev
Suspend 12
Process State Transition Diagram
Suspend Blocked
New
Ad
t
mi
mi
Ad
Suspe
t
nd
Activate Dispatch
Ready/ Release
Suspend Ready Running Exit
Suspend Timeout
t
ai
Occurs
Occurs
Event
Event
tW
en
Ev
Activate
Blocked/
Suspend
Blocked
Suspend
Process
Image
Memory Tables
Process
Memory 1
Files
Process 1
Process 2
Process
Process 3 Image
Process
n
Process n
Existence of files
Current Status
Attributes
19
Primary Process Table
Process ID
Location in memory
20
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.
Process Identification :
Process Identifier
Parent Process Identifier
User Identifier
22
Process Control Block (2)
User-Visible Registers
Control & Status Registers
Program counter
Program status word (PSW)
Stack Pointers
23
Process Control Block (3)
Memory Management
I/O Management
•Buffer management
•Allocation of I/O channels and devices to processes
Support Functions
•Interrupt handling
•Accounting
•Monitoring
26
Process Creation
Interrupt
Clock interrupt ( ready state)
I/O interrupt (running state / ready state)
Memory Fault ( blocked state)
Trap ( exit state / running state)
Supervisor call ( blocked state)
29
Processor Execution Mode
User Mode
Less-privileged mode
User programs typically execute in this mode
Mode switching :
User mode (A) Kernel mode User mode (A)
Process switching :
User mode (A) Kernel mode User mode (B)
update the
move the process
save the context of process control
control block of this
the processor block of the
process to the
process currently in
appropriate queue
the Running state
select another
process for
execution
Non-process Kernel
execute kernel outside of any process
operating system code is executed as a separate entity
that operates in privileged mode
33
Execution of Operating System (2)
Process Control
Information
User Stack
Private User
Address Space
(Programs, Data)
Kernel Stack
Shared Address
Space
User Process
37
Process Description
Created
Preempted
User
Running preempt
swap out
return Ready to Run Ready to Run
reschedule
In Memory Swapped
process swap in
system call,
interrupt Kernel
Running