Lecture 2 - Process Management Part 2 Process States
Lecture 2 - Process Management Part 2 Process States
2
3 1
Blocked
10
CPU Switch From Process to Process
Process Control Block (PCB)
• Each process is represented in a operating system by a Process
Control Block (PCB) which has following information:
• Process state
• Program counter (PC)
• CPU scheduling information
• Memory-management information
• Accounting information
• I/O status information
Implementation of Process Context
Right Operand
Left Operand Status
Registers
R1
R2
...
Rn
Functional Unit
Result ALU
PC
IR
Ctl Unit
Context Switching
• Context Switching: We need to save the context of the current running process so it can be resumed af
the interrupt is handled.
15
Context Switching
Old Process/Thread
Descriptor(PCB)
CPU
New Process/Thread
Descriptor(PCB)
Process Scheduling Queues
• The OS maintains all PCBs in Process
Scheduling Queues.
• The OS maintains a separate queue for each
of the process states and PCBs of all
processes in the same execution state are
placed in the same queue.
• When the state of a process is changed, its PCB
is unlinked from its current queue and moved to
its new state queue.
17
Implementation of Processes
18
Process Scheduling
• As processes enters the system, they are put into
Job queue
• The processes that are stay in main memory and are ready and
waiting to execute are kept on a list called Ready queue
• A ready queue contains pointers to the first and final PCBs in the list
• The list of processes waiting for a particular I/O is called a Device
queue
Ready Queue And Various I/O Device Queues
Printer
1
Printer
2
Queueing Diagram
A new process is initially put in the ready queue, once the process is
located in CPU, one of several events may occur:
• The process issue a I/O request, and then be placed in I/O queue
• The process create a new subprogram and wait for the sub process’
termination
• The process could be removed from CPU and be placed back to ready
queue
Queueing Diagram
Types of Processes
Processes can be described as either:
• I/O-bound process–spends more time doing I/O than computations,
many short CPU bursts
• CPU-bound process–spends more time doing computations; few very
long CPU bursts
Types of Processes
24
Model of Process Execution
34
Scheduling Criteria / Goals
1. CPU Utilization:
• the percentage of time the CPU is executing a process.
• The load on the system affects the level of utilization
that can be achieved;
• High Utilization – is more easily achieved on more heavily
loaded systems
• For example: on a single-user system, CPU utilization is
relatively unimportant where as on a large, expensive,
time-shared system, it may be the primary
consideration.
35
Scheduling Criteria / Goals
2. Balanced Utilization:
• The percentage of time all resources are utilized.
• Instead of just evaluating CPU utilization, utilization of
memory, I/O devices, and other system resources are also
considered.
36
Scheduling Criteria / Goals
3. Throughput:
• The number of processes the system can execute in a
period of time.
• The average length of the processes must be
considered in calculation of Throughput.
• For Example: on a system with long processes, the
throughput will be less as compared with systems with
short processes.
37
Scheduling Criteria / Goals
4. Turnaround Time:
• The average period of time it takes a process to
execute.
• It includes all the time that a process spends in the
system.
• It is computed by the subtracting the time the process
was created from the time it is terminated.
38
Scheduling Criteria / Goals
5. Wait Time:
• The average period of time a process spends waiting.
39
Scheduling Criteria / Goals
6. Response Time:
• On an interactive systems, the average time it takes
the system to start responding to the user inputs.
40
Scheduling Criteria / Goals
7. Predictability:
• Lack of variability in other measures of performance.
• Users prefer consistency
• For example: response time in an interactive systems is
generally a second but occasionally they take 10s to
respond….such systems are not preferred by users
41
Scheduling Criteria / Goals
8. Fairness:
• The degree to which all the processes are given equal
opportunity to execute.
• Systems which do not allow a process to suffer from
Starvation, i.e, a process is stuck in a scheduling queue
indefinitely.
42
Scheduling Criteria / Goals
9. Priorities:
• Give preferential treatment to processes with higher
priority.
43
Optimization Criteria
• Max CPU utilization
• Max throughput
• Min turnaround time
• Min waiting time
• Min response time
44
Scheduling Algorithm Goals – To identify the process whose selection will result
in the “BEST” possible system performance
45