1 1 Process Description and Control Chapter 3 Sequence 5 CS240 2 Requirements of an Operating System • Interleave the execution of multiple processes to maximize processor utilization while providing reasonable response time • Allocate resources to processes • Support interprocess communication and user creation of processes
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
1
Process Description and Control
Chapter 3
Sequence 5 CS240 2
Requirements of an Operating System
• Interleave the execution of multiple processes to maximize processor utilization while providing reasonable response time
• Allocate resources to processes • Support interprocess communication and
user creation of processes
2
Sequence 5 CS240 3
Manage Execution of Applications
• Resources made available to multiple applications
• Processor is switched among multiple application
• The processor and I/O devices can be used efficiently
Sequence 5 CS240 4
Process • A program in execution • An instance of a program running on a
computer • The entity that can be assigned to and
executed on a processor • A unit of activity characterized by the
execution of a sequence of instructions, a current state, and an associated set of system instructions
3
Sequence 5 CS240 5
Process Elements • Identifier • State • Priority • Program counter • Memory pointers • Context data • I/O status information • Accounting information
Sequence 5 CS240 6
Process Control Block
• Contains the process elements • Created and manage by the operating
system • Allows support for multiple processes
4
Sequence 5 CS240 7
Process Control Block Identifier
Figure 3.1 Simplified Process Control Block
State
Priority
Program counter
Memory pointers
Context data
I/O statusinformation
Accountinginformation
Sequence 5 CS240 8
Trace of Process
• Sequence of instruction that execute for a process
• Dispatcher switches the processor from one process to another
5
Sequence 5 CS240 9
Example Execution Main MemoryAddress
Dispatcher
Process A
Process B
Process C
Program Counter0
100
5000
8000
8000
12000
Figure 3.2 Snapshot of Example Execution (Figure 3.4)at Instruction Cycle 13
Sequence 5 CS240 10
Trace of Processes
Process B is waiting for I/O
6
Sequence 5 CS240 11
Sequence 5 CS240 12
Two-State Process Model • Process may be in one of two states
– Running – Not-running
7
Sequence 5 CS240 13
Not-Running Process in a Queue
Sequence 5 CS240 14
Process Creation
8
Sequence 5 CS240 15
Process Termination
Sequence 5 CS240 16
Process Termination
9
Sequence 5 CS240 17
Processes
• Not-running – ready to execute
• Blocked – waiting for I/O
• Dispatcher cannot just select the process that has been in the queue the longest because it may be blocked
Sequence 5 CS240 18
A Five-State Model
• Running • Ready • Blocked • New • Exit
10
Sequence 5 CS240 19
Five-State Process Model
Sequence 5 CS240 20
Let’s look at the execution again. What are the state transitions of the processes?
11
Sequence 5 CS240 21
Process States
Sequence 5 CS240 22
Using Two Queues
Is the Blocked Queue a FIFO queue? What is the problem with the Blocked Queue?
12
Sequence 5 CS240 23
Multiple Blocked Queues
Event 1 Wait
Event 2 Wait
Event n Wait
DispatchReleaseReady Queue
AdmitProcessor
Timeout
Event 1 QueueEvent 1Occurs
Event 2Occurs
Event nOccurs
Event 2 Queue
Event n Queue
(b) Multiple blocked queues
Sequence 5 CS240 24
Suspended Processes • Processor is faster than I/O so all
processes could be waiting for I/O • Swap these processes to disk to free up