Lec+2 +OS+Part+1
Lec+2 +OS+Part+1
Operating
Systems
Operating
system OS Road Map
Concepts
+
Process
+ synchronization
+
Processes&
Threads
+
CPU
Scheduling
+
Memory
©Ahmed Operating Management
2
Hagag Systems
Reference
Computer Operating System Concepts
• Author: Silberschatz
• Publisher: Wiley
• Edition: Sixth
• ISBN: 0471250600
Operating System
What Operating Systems Do?
• OS is a resource allocator
Manages all resources.
Decides between conflicting requests for effici
ent and fair resource use.
• OS is a control program
Controls execution of programs to prevent
errors and improper use of the computer.
©Ahmed Operating 4
Hagag Systems
Single processor
• Memory Layout for a Simple Batch System
Single processor
• Multi-programmed Batch Systems
• Several jobs are kept in main memory at the same time, and the CPU is
multiplexed among them
• OS features needed
• I/O routine supplied by the system
• Memory management
• The system must allocate the memory
to several jobs
• CPU scheduling
• The system must choose among
several jobs ready to run
Parallel Systems
• Systems with more than one CPU in close communication
• Also known as multiprocessor systems
• Tightly coupled system
• processors share memory and a clock;
• communication usually takes place through the shared memory
• Advantages of parallel system:
• Increased throughput
• Economical
• Increased reliability
• graceful degradation
Distributed Systems
• Distribute the computation among several physical processors
• Loosely coupled system
• Each processor has its own local memory
• processors communicate with one another through various
communications lines, such as high-speed buses or telephone lines
• Advantages of distributed systems
• Resources Sharing
• Computation speed up
• Reliability
Difference between clustered system and
distributed system
• Distributed System:
A distributed system refers to a collection of independent
computers or nodes that work together as a single cohesive
system. These nodes are connected through a network and
communicate with each other to achieve a common goal.
• In a distributed system, the nodes are geographically dispersed
and can be heterogeneous, meaning they may have different
hardware configurations, operating systems, or software
components
Difference between clustered system and
distributed system
1. Distributed System:
Decentralization: There is no central control or single point of failure in a
distributed system. Each node operates independently and makes its
own decisions.
2. Autonomy: Each node in a distributed system has its own local memory
and processing capabilities, allowing it to perform tasks independently.
3. Transparency: The system appears as a single, integrated entity to
users and applications, hiding the complexity of the underlying network
and node interactions.
4. Scalability: Distributed systems can scale horizontally by adding more
nodes to the network, increasing processing power and storage capacity.
5. Fault tolerance: Distributed systems are designed to handle failures or
crashes of individual nodes without disrupting the overall system.
Examples of distributed systems include peer-to-peer networks,
distributed file systems, and distributed databases.
Distributed Systems Cont’d
• Requires networking infrastructure
• Local area networks (LAN) or Wide area networks (WAN)
• May be either client-server or peer-to-peer systems
Clustered Systems
• Clustered System:
A clustered system is a type of parallel computing architecture
in which multiple computers or servers, known as nodes, are
tightly interconnected and work together to perform a specific
task or provide a service.
• In a cluster, the nodes are typically located in close proximity
and are homogeneous, meaning they have similar hardware
configurations and software setups.
Clustered Systems
• Clustering allows two or more systems to
share storage
©Ahmed Operating 15
Hagag Systems
Operating System
What Operating Systems Do?
• OS is a resource allocator
Manages all resources.
Decides between conflicting requests for effici
ent and fair resource use.
• OS is a control program
Controls execution of programs to prevent
errors and improper use of the computer.
©Ahmed Operating 16
Hagag Systems
Process Concept
©Ahmed Operating 17
Hagag Systems
Process Concept
• The fundamental task of any operating system i
s the
process management.
• Processes include not only a text but also include a set of resources
such as open f il es and pending signals. Processes also contain
internal kernel data, processor state, an address space, and a data
section.
©Ahmed Operating 18
Hagag Systems
Process Concept
• OS must allocate resources to processes, enable sharing of
information, protect resources, and enable the synchronization
among processes.
©Ahmed Operating 19
Hagag Systems
Process Elements
©Ahmed Operating 20
Hagag Systems
Process Concept
• Process in
Memory
©Ahmed Operating 21
Hagag Systems
Process Control Block (PCB)
©Ahmed Operating 22
Hagag Systems
Process Control Block (PCB)
• Process Control Block (PCB) (1/3)
Process identification information
Process identifier: numeric identifiers
represent the unique process identifier
User identifier: the user who is responsible for the job).
Identif ier of the parent process that created this
process.
©Ahmed Operating 23
Hagag Systems
Process Control Block (PCB)
©Ahmed Operating 24
Hagag Systems
Process Control Block (PCB)
• Process Control Block (PCB) (3/3)
CPU scheduling information
priorities, scheduling queue pointers
Memory-management information
memory allocated to the process
Accounting information
CPU used, clock time elapsed since start, time
limits
I/O status information
I/O devices allocated to process, list of open
©Ahmed Operating 25
Hagag f iles Systems
Process State
©Ahmed Operating 26
Hagag Systems
Process State
• Diagram of Process
State
©Ahmed Operating 27
Hagag Systems
Process State
©Ahmed Operating 28
Hagag Systems
Process State
©Ahmed Operating 29
Hagag Systems
Process State
©Ahmed Operating 30
Hagag Systems
Process State
©Ahmed Operating 31
Hagag Systems
Process State
©Ahmed Operating 32
Hagag Systems
Process State
©Ahmed Operating 33
Hagag Systems
CPU Switch From Process to
Process
©Ahmed Operating 34
Hagag Systems
Process Scheduling
• Job queue – set of all processes in the system
• Ready queue – set of all processes
residing in main memory, ready and waiting
to execute
• Device queues – set of processes waiting for an I/O device
• Processes migrate among the various queues
©Ahmed Operating 35
Hagag Systems
Process Scheduling
• Short-term scheduler (or CPU scheduler)
Selects which process should be executed next and allocates CPU.
Invoked frequently (milliseconds) →(must be fast).
• Long-term scheduler (or job scheduler)
Selects which processes should be brought into the
ready queue.
Invoked infrequently (seconds, minutes) →(may be slow).
Controls the degree of multiprogramming.
©Ahmed Operating 36
Hagag Systems
Process Scheduling
Medium-term scheduler
Can be added if degree of multiple programmi
ng needs to decrease
Remove process from memory, store on disk, bring back in
from disk to continue execution: swapping
©Ahmed Operating 37
Hagag Systems
Operating systems
Threads
©Ahmed Operating 38
Hagag Systems
Introduction
• It shares with other threads belonging to the same process its code
©Ahmed Operating 39
Hagag Systems
CONT’S Introduction
• The program must give its full attention to the keyboard input
©Ahmed Operating 41
Hagag Systems
Operating
Systems
CPU Scheduling
Operating system
CPU Scheduling
©Ahmed Operating 43
Hagag Systems
Basic Concepts
• CPU scheduling is the central in multi-
programming system.
• Maximum CPU utilization obtained with
multiprogramming (prevent CPU from being idle).
• Processes residing in the main memory is selected by the
Scheduler that is:
Concerned with deciding a policy about which process is to
be selected.
Process selection based on a scheduling algorithm.
©Ahmed Operating 44
Hagag Systems
Basic Concepts
©Ahmed Operating 45
Hagag Systems
Basic Concepts
©Ahmed Operating 46
Hagag Systems
Basic Concepts
• Process execution consists of a
cycle of CPU execution and I/O wait.
• Processes alternate between these
t w o st at es. Proc ess exec ut ion
begins with a CPU burst. That is
followed by an I/O burst, which is
followed by another CPU burst, then
another I/O burst, and so on.
• CPU burst s vary greatly from
p roc ess to p roc ess and from
computer to computer.
©Ahmed Operating 47
Hagag Systems
Basic Concepts
Schedulers
• Long-term scheduler chooses some of them to go to
memory (ready queue).
• Then, short-term scheduler (or CPU scheduler) chooses
from ready queue a job to run on CPU.
• Medium-term scheduler may move (swap) some partially-
e x e c u t e d j o b s f ro m m e m o r y t o d i s k ( t o e n h a n c e
performance).
©Ahmed Operating 48
Hagag Systems
Basic Concepts
CPU Scheduler
• Whenever the CPU becomes idle, the operating system must
select one of the processes in the ready queue to be executed.
The selection process is carried out by the short-term scheduler,
or CPU scheduler.
©Ahmed Operating 49
Hagag Systems
Basic Concepts
©Ahmed Operating 50
Hagag Systems
Basic Concepts
Scheduling can be
• Non-preemptive
Once a process is allocated the CPU, it
does not leave until terminate.
• Preemptive
OS can force (preempt) a process from CPU
at anytime.
Say, to allocate CPU to another higher-priority process.
©Ahmed Operating 51
Hagag Systems
Basic Concepts
©Ahmed Operating 52
Hagag Systems
Basic Concepts
©Ahmed Operating 53
Hagag Systems
Basic Concepts
Dispatcher
• Dispatcher module gives control of the CPU to the process
selected by the short-term scheduler; this involves:
Switching context.
Switching to user mode.
Jumping to the proper location in the user program to restart
that program.
• Dispatch latency – time it takes for the dispatcher to stop
one process and start another running.
©Ahmed Operating 54
Hagag Systems
Basic Concepts
Dispatcher
©Ahmed Operating 55
Hagag Systems
Basic Concepts
Dispatch
er
©Ahmed Operating 56
Hagag Systems
Basic Concepts
Dispatch
er
©Ahmed Operating 57
Hagag Systems
Basic Concepts
Dispatch
er
©Ahmed Operating 58
Hagag Systems
Basic Concepts
• CPU utilization – keep the CPU as busy as possible.
• Throughput – #of processes that complete their execution per time unit.
• Turnaround time – amount of time to execute a particular process. (time from
submission to termination)
• Waiting time – amount of time a process has been waiting in the ready queue.
• Response time – amount of time it takes from when a request was submitted
until the f irst response is produced, not output.
©Ahmed Operating 59
Hagag Systems
Scheduling Criteria
Scheduling Algorithm Optimization
Criteria
©Ahmed Operating 60
Hagag Systems
Scheduling Algorithms
• There are many different CPU-scheduling algorithms:
1. First Come, First Served (FCFS).
2. Shortest Job First (SJF).
Preemptive SJF.
Non-Preemptive SJF.
3. Priority.
4. Round Robin.
5. Multilevel queues.
©Ahmed Operating 61
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 , P2 , P3
The Gantt Chart for the schedule is:
©Ahmed Operating 62
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 ,
P2 , P3
The Gantt Chart for the schedule is:
P1
0
©Ahmed Operating 63
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 ,
P2 , P3
The Gantt Chart for the schedule is:
P1
0
©Ahmed Operating 64
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 ,
P2 , P3
The Gantt Chart for the schedule is:
P1
0
©Ahmed Operating 65
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 ,
P2 , P3
The Gantt Chart for the schedule is:
P1
0
Waiting Time
��� ��� ����
� �
©Ahmed Operating 66
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 ,
P2 , P3
The Gantt Chart for the schedule is:
P1
0
Waiting Time
���� ��� ����
�
0 24 27
Average waiting time: (0 + 24 + 27)/3 =
17
©Ahmed Operating 67
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 ,
P2 , P3
The Gantt Chart for the schedule is:
P1
0
Turnaround Time
��� ��� ����
� �
©Ahmed Operating 68
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 ,
P2 , P3
The Gantt Chart for the schedule is:
P1
0
Turnaround Time
��� ��� ����
� �
24 27 30
Average turnaround time: (24 + 27 + 30)/3 =
27
©Ahmed Operating 69
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 ,
P2 , P3
The Gantt Chart for the schedule is:
P1
0
Response Time
��� ��� ����
� �
©Ahmed Operating 70
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 ,
P2 , P3
The Gantt Chart for the schedule is:
P1
0
Response Time
���� ��� ����
�
0 24 27
Average response time: (0 + 24 + 27)/3 =
17
©Ahmed Operating 71
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P2 ,
P3 , P1
The Gantt Chart for the schedule is:
©Ahmed Operating 72
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P2 ,
P3 , P1
The Gantt Chart for the schedule is:
P2 P3 P
0
©Ahmed Operating 73
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P2 ,
P3 , P1
The Gantt Chart for the schedule is:
P2 P3 P
0
©Ahmed Operating 74
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P2 ,
P3 , P1
The Gantt Chart for the schedule is:
P2 P3 P
0
©Ahmed Operating 75
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P2 ,
P3 , P1
The Gantt Chart for the schedule is:
P2 P3 P
0
Waiting Time
��� ��� ����
� �
©Ahmed Operating 76
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P2 ,
P3 , P1
The Gantt Chart for the schedule is:
P2 P3 P
0
Waiting Time
���� ���� ����
6 0 3
Turnaround Time
��� ��� ����
� �
©Ahmed Operating 78
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P2 ,
P3 , P1
The Gantt Chart for the schedule is:
P2 P3 P
0
Turnaround Time
��� ���� ����
�
30 3 6
Average turnaround time: (30 + 3 + 6)/3 =
13
©Ahmed Operating 79
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P2 ,
P3 , P1
The Gantt Chart for the schedule is:
P2 P3 P
0
Response Time
��� ��� ����
� �
©Ahmed Operating 80
Hagag Systems
Scheduling Algorithms
1. First-Come, First-Served (FCFS) Scheduling
Process Burst
Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P2 ,
P3 , P1
The Gantt Chart for the schedule is:
P2 P3 P
0
Response Time
���� ���� ����
6 0 3
©Ahmed Operating 84
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF)
Scheduling Process Burst
Time
P1 6
P2 8
P3 7
P4 3
SJF scheduling
chart
P4 P1 P3 P2
0 3 9 16 24
©Ahmed Operating 85
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF)
Scheduling Process Burst
Time
P1 6
P2 8
P3 7
P4 3
SJF scheduling
chart
P4 P1 P3 P2
0 3 9 16 24
©Ahmed Operating 86
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF)
Scheduling Process Burst
Time
P1 6
P2 8
P3 7
P4 3
SJF scheduling
chart
P4 P1 P3 P2
0 3 9 16 2
4
©Ahmed Operating 87
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF)
Scheduling Process Burst
Time
P1 6
P2 8
P3 7
P4 3
SJF scheduling
chart
P4 P1 P3 P2
0 3 9 16 24
©Ahmed Operating 88
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF)
Scheduling Process Burst
Time
P1 6
P2 8
P3 7
P 3
SJF scheduling4
chart
P4 P1 P3 P2
0 3 9 16 24
Waiting Time
�� �� �� ��
�� �� �� ��
©Ahmed Operating 89
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF)
Scheduling Process Burst
Time
P1 6
P2 8
P3 7
P 3
SJF scheduling4
chart
P4 P1 P3 P2
0 3 9 16 24
Waiting Time
��� �� ���� ����
� ��
3 16 9 0
Average waiting time: (3 + 16 + 9 + 0)/4 =
7
©Ahmed Operating 90
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF)
Scheduling Process Burst
Time
P1 6
P2 8
P3 7
P 3
SJF scheduling4
chart
P4 P1 P3 P2
0 3 9 16 24
Turnaround Time
�� �� �� ��
�� �� �� ��
©Ahmed Operating 91
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF)
Scheduling Process Burst
Time
P1 6
P2 8
P3 7
P 3
SJF scheduling4
chart
P4 P1 P3 P2
0 3 9 16 24
Turnaround Time
��� �� �� ����
� �� ��
9 24 16 3
Average Turnaround time: (9 + 24 + 16 + 3)/4 =
13
©Ahmed Operating 92
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF)
Scheduling Process Burst
Time
P1 6
P2 8
P3 7
P 3
SJF scheduling4
chart
P4 P1 P3 P2
0 3 9 16 24
Response Time
�� �� �� ��
�� �� �� ��
©Ahmed Operating 93
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF)
Scheduling Process Burst
Time
P1 6
P2 8
P3 7
P 3
SJF scheduling4
chart
P4 P1 P3 P2
0 3 9 16 24
Response Time
��� �� ���� ����
� ��
3 16 9 0
Average Response time: (3 + 16 + 9 + 0)/4
=7
©Ahmed Operating 94
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF) (Non-Preemptive SJF )
Now we add the concepts of varying arrival times and
preemption to the analysis
Process Arrival Time Burst
Time
P1 0 1
P2 1 4
P3 2 7
P4 3 5
Non-Preemptive SJF Gantt
Chart
©Ahmed Operating 95
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF) (Non-Preemptive SJF )
Now we add the concepts of varying arrival times and
preemption to the analysis
Process Arrival Time Burst
Time
P1 0 1
P2 1 4
P3 2 7
P4 3 5
Non-Preemptive SJF Gantt
Chart
P1 P2 P4 P1 P3
0 1 5 10 17 26
©Ahmed Operating 96
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF) (Non-Preemptive SJF )
Now we add the concepts of varying arrival times and
preemption to the analysis
Process Arrival Time Burst
Time
P1 0 1
P2 1 4
P3 2 7
P4 3 5
Non-Preemptive SJF Gantt
Chart
P1 P2 P4 P1 P3
0 1 5 10 17 26
©Ahmed Operating 97
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF) (Non-Preemptive SJF )
Now we add the concepts of varying arrival times and
preemption to the analysis
Process Arrival Time Burst
Time
P1 0 1
P2 1 4
P3 2 7
P4 3 5
Non-Preemptive SJF Gantt
Chart
P1 P2 P4 P1 P3
0 1 5 10 17 26
©Ahmed Operating 98
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF) (Non-Preemptive SJF )
Now we add the concepts of varying arrival times and
preemption to the analysis
Process Arrival Time Burst
Time
P1 0 1
P2 1 4
P3 2 7
P4 3 5
Non-Preemptive SJF Gantt
Chart
©Ahmed Operating 99
Hagag Systems
Scheduling Algorithms
2.1 Shortest-Job-First (SJF) (Non-Preemptive SJF )
Now we add the concepts of varying arrival times and
preemption to the analysis
Process Arrival Time Burst
Time
P1 0 1
P2 1 4
P3 2 7
P4 3 5
Non-Preemptive SJF Gantt
Chart
Waiting Time
��� ��� ���� ���
� � �
4. Define : n 1
t n
1
n
.
Commonly, set to ½
Preemptive version called shortest-remaining-time-
©Ahmed
f irst Operating 106
Hagag Systems
Scheduling Algorithms
Prediction of the Length of the Next CPU
Burst
Waiting Time
��� ��� ���� ���
� � �
Waiting Time
���� ���� ���� ����
10 − 1 1 −1 17 − 2 5−3
= �� = �� = ���� = �� Average waiting time = [9+0+15+2]/4 = 26/4 = 6.5
msec
©Ahmed Operating 120
Hagag Systems
Scheduling Algorithms
2.2 Shortest-remaining-time-f irst (Preemptive SJ
F) Process Arrival Time Burst
Time
P1 0 8
P2 1 4
P3 2 9
P4 3 5
Preemptive SJF Gantt
Chart
P1 P2 P4 P1 P3
0 1 5 10 17 26
Turnaround Time
��� ��� ���� ���
� � �
Turnaround Time
���� ���� ���� ����
17 − 0 5 −1 26 − 2 10 − 3
= ��� = �� = ���� = �� Average turnaround time = [17+4+24+7]/4 = 52/4 = 13
� msec
©Ahmed Operating 122
Hagag Systems
Scheduling Algorithms
2.2 Shortest-remaining-time-f irst (Preemptive SJ
F) Process Arrival Time Burst
Time
P1 0 8
P2 1 4
P3 2 9
P4 3 5
Preemptive SJF Gantt
Chart
P1 P2 P4 P1 P3
0 1 5 10 17 26
Response Time
��� ��� ���� ���
� � �
Response Time
���� ���� ���� ����
0−0 1 −1 17 − 2 5−3
= �� = �� = ���� = �� Average response time = [0+0+15+2]/4 = 17/4 = 4.25
msec
©Ahmed Operating 124
Hagag Systems
Scheduling Criteria
• CPU utilization – keep the CPU as busy as possible.
• Throughput – #of processes that complete their execution per time unit.
• Turnaround time – amount of time to execute a particular process. (time
from submission to termination)
• Waiting time – amount of time a process has been waiting in the ready
queue.
• Response time – amount of time it takes from when a request was
submitted until the f irst response is produced, not output.
The CPU is allocated to the process with the highest priority (smallest integer
highest priority)
Preemptive
Nonpreemptive
SJF is priority scheduling where priority is the inverse of predicted next CPU
burst time
Waiting Time
�� �� �� �� ���
�� �� �� �� �
Waiting Time
���� ��� �� �� ���
� �� �� � Average Waiting time = [6+0+16+18+1]/5 = 8.2
6 0 16 18 1 msec
Turnaround Time
�� �� �� �� ���
�� �� �� �� �
Turnaround Time
�� ��� �� �� ���
�� � �� �� � Average Turnaround time = [16+1+18+19+6]/5 = 12
16 1 18 19 6 msec
Response Time
�� �� �� �� ���
�� �� �� �� �
Response Time
���� ��� �� �� ���
� �� �� � Average Response time = [6+0+16+18+1]/5 = 8.2
6 0 16 18 1 msec
0 4 7 10 14 18 22 26 30
0 4 10 14 18 22 26 30
7
0 4 7 10 14 18 22 26 30
0 4 7 10 14 18 22 26 30
0 4 7 10 14 18 22 26 30
# of context switches =
??
# of context switches
=7
Waiting Time
���� ��� ���
� �
Waiting Time
���� ���� ����
0 + (10 − 4) 4 7
Turnaround Time
���� ��� ���
� �
Turnaround Time
���� ���� ���
�
30 7 10
Average Turnaround time: (30 + 7 + 10)/3 = 15.667
ms
©Ahmed Operating 159
Hagag Systems
Scheduling Algorithms
4. Round Robin (RR) Scheduling
Process Burst
Time
P1 24
P2 3
All the processes arrive atP3the same time 0.
3
Round Robin (RR) scheduling of quantum: 4
ms
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
Response Time
���� ��� ���
� �
Response Time
���� ���� ����
0 4 7
P �
3 2 20 �
P4 3 40 2
�
�0
�
�1
�
©Ahmed �2 Operating 169
Hagag Systems
Scheduling Algorithms
�
5. Multilevel Queue �
SchedulingProcess Arrival Time Burst 0
�
Time
�1
P1 0 7
P2 1 60
3 �
P 2 20
�2
P4 3 40
7m 7ms
s
� ��1
�
0
�
�1
�
�
©Ahmed Operating 170
Hagag 2 Systems
Scheduling Algorithms
�
5. Multilevel Queue �
SchedulingProcess Arrival Time Burst 0
�
Time
�1
P1 0 7
P2 1 60
3 �
P 2 20
�2
P4 3 40
7m
� s
�0 7ms 8ms
��1 ��2
�
�1
�
©Ahmed �2 Operating 171
Hagag Systems
Scheduling Algorithms
�
5. Multilevel Queue �
SchedulingProces Arrival Time Burst 0
�
s Time 0 7 �
P1 P2 1 60 1
P �
3 2 �
P4 52
3 2
20
15m 40
7m 8m s
s s
� ��1 ��2
�
0
�
�1
�
�
©Ahmed Operating 172
Hagag 2 Systems
Scheduling Algorithms
�
5. Multilevel Queue �
SchedulingProces Arrival Time Burst 0
�
s Time 0 7 �
P1 P2 1 60 1
P �
3 2 �
P4 52
3 2
20
15m 40
7m 8m s 8m
s s s
� ��1 ��2 ��3
�
0
� ��2
�
1
�
�
2
©Ahmed Operating 173
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue Scheduling
��0
Process Arrival Time Burst Time
P1 0 7
��1 P2 1 60 52 44
P3 2 20 12
��2 P4 3 40
23ms
7m 8m 8m
s s s
� ��1 ��2 ��3
�
0
� ��2
�
1
�
�
2
©Ahmed Operating 174
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProcess Arrival Time Burst Time
��0 P1 0 7
P2 1 60 52 44
��1 P3 2 20 12
P4 3 40
��2
23ms
7ms 8ms 8ms 8ms
� ��1 ��2 ��3 �
�0 �4
� ��2
�1
�
©Ahmed �2 Operating 175
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue Scheduling
��0
Process Arrival Time Burst Time
P1 0 7
��1 P2 1 60 52 44 36
P3 2 20 12
��2 P4 3 40 32
31ms
7m 8m 8m 8m
s s s s
� ��1 ��2 ��3 ��4
�
16ms
0
� ��2
�
1
�
�
2
©Ahmed Operating 176
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue Scheduling
��0
Process Arrival Time Burst Time
P1 0 7
��1 P2 1 60 52 44 36
P3 2 20 12
��2 P4 3 40 32
31ms
7m 8m 8m 8m
s s s s
� ��1 ��2 ��3 ��4
�
16ms 12ms
0
� ��2 ��3
�
36ms
1
� �
� �
2
©Ahmed Operating 2
177
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time Burst
s Time 0 7
0
� P1 P2 1 60 52 4
�
P3 P4 2 4 36 2
1
� 4
3
� 20 12
2 43 m 40 32
7m 8m 8m 8m s
s s s s
� ��1 ��2 ��3 ��4
�
16m 12m
0 s s
� ��2 ��3
�
36ms
1
� ��2
�
2
©Ahmed Operating 178
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time Burst
s Time 0 7
0
� P1 P2 1 60 52 4
�
P3 P4 2 4 36 2
1
� 4
3
� 20 12
2 43 m 40 32
7m 8m 8m 8m s
s s s s
� ��1 ��2 ��3 ��4
�
16m 12m 16ms
0 s s
� ��2 ��3 ��4
�
36ms
1
� ��2
�
2
©Ahmed Operating 179
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue Scheduling
��0
Process Arrival Time Burst Time
P1 0 7
��1 P2 1 60 52 44 36 24 8
P3 2 20 12
��2 P4 3 40 32 16
59ms
7m 8m 8m 8m
s s s s
� ��1 ��2 ��3 ��4
�
16m 12m 16m
0 s s s
� ��2 ��3 ��4
�
36ms
1
� �
� �
2
©Ahmed Operating 2
180
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time Burst
s Time 0 7
0
� P1 P2 1 60 52 44
�
P3 P4 2 36 24
1
� 8
3
� 20 12
2
40 32 67m16
7m 8m 8m 8m s
s s s s
� ��1 ��2 ��3 ��4
�
16m 12m 16m
0 s s s
� ��2 ��3 ��4
�
36ms
1
� �
� �
2
©Ahmed Operating 2
181
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time Burst
s Time 0 7
0
� P1 P2 1 60 52 44
�
P3 P4 2 36 24
1
� 8
3
� 20 12
2
40 32 67m16
7m 8m 8m 8m s
s s s s
� ��1 ��2 ��3 ��4
�
16m 12m 16m
0 s s s
� ��2 ��3 ��4
�
36ms 16ms
1
� � ��4
� �
2
©Ahmed Operating 2
182
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time Burst
s Time 0 7
0
� P1 P2 1 60 52 44
�
P3 P4 2 36 24
1
� 8
3
� 20 12
2
40 32 16 83m
7m 8m 8m 8m s
s s s s
� ��1 ��2 ��3 ��4
�
16m 12m 16m
0 s s s
� ��2 ��3 ��4
�
36m 16m
1 s s
� � ��4
� �
2
©Ahmed Operating 2
183
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time Burst
s Time 0 7
0
� P1 P2 1 60 52 44
�
P3 P4 2 36 24
1
� 8
3
� 20 12
2 7ms 15ms 23ms 43 m 40 59 32ms 16 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 184
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Process Arrival
Waiting Time
Time
1 0
0
� �� ��� ���� ����
P
P2 1
� �� �
1
P3 2
� P4 3
�
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 185
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Process Arrival
Waiting Time
Time
1 0
0
� �� ��� ���� ����
P
P2 1
� �� �
1
P3 2 0
� P4 3 = �
� �
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 186
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Process Arrival
Waiting Time
Time
1 0
0
� �� ���� ���� ����
P
P2 1
� ��
1
P3 2 0 7−1
� P4 3 = � = ��
� �
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 187
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Process Arrival
Waiting Time
Time
1 0
0
� �� ���� ���� ����
P
P2 1
� ��
1
P3 2 0 7−1 15 + 8 − 2
� P4 3 = � = �� = ����
� �
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 188
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Process Arrival
Waiting Time
Time
1 0
0
�� ���� ���� ����
� P
P2 1
� ��
P3 2 0 7−1 15 + 8 − 2 23 + 12 + 8 − 3
1
� P4 3 = � = �� = ���� = ����
� �
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 189
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time
Turnaround Time
s 0
0
��� ��� ��� ����
� P1 P 1
2
� � � �
1
P3 2
� P4 3
�
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 190
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time
Turnaround Time
s 0
0
���� ��� ��� ����
� P1 P 1
2
� � �
1
P3 2 7−0
� P4 3 = ��
�
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 191
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time
Turnaround Time
s 0
0
���� ���� ��� ����
� P1 P 1
2
� �
1
P3 2 7−0 67 − 1
� P4 3 = �� = ���
� �
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 192
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time
Turnaround Time
s 0
0
���� ���� ���� ����
� P1 P 1
2
� 7−0 67 − 1 43 − 2
1
P3 2
= �� = ��� = ����
� P4 3 �
�
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 193
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time
Turnaround Time
s 0
0
���� ���� ���� ����
� P1 P 1
2
� 7−0 67 − 1 43 − 2 83 − 3
1
P3 2
= �� = ��� = ���� = ����
� P4 3 �
�
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 194
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time
Response Time
s 0
0
��� ��� ��� ����
� P1 P 1
2
� � � �
1
P3 2
� P4 3
�
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 195
Hagag Systems
5. Multilevel Queue
Scheduling Algorithms (24/3
�
Scheduling
�
Proces Arrival Time
Response Time
s 0
0
���� ��� ��� ����
� P1 P 1
2
� � �
1
P3 2 0−0
� P4 3 = ��
�
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 196
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time
Response Time
s 0
0
���� ���� ��� ����
� P1 P 1
2
� �
1
P3 2 0−0 7−1
� P4 3 = �� = ��
�
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 197
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time
Response Time
s 0
0
���� ���� ���� ����
� P1 P 1
2
� 0−0 7−1 15 − 2
1
P3 2
= �� = �� = ����
� P4 3
�
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 198
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
�
Scheduling
�
Proces Arrival Time
Response Time
s 0
0
���� ���� ���� ����
� P1 P 1
2
� 0−0 7−1 15 − 2 23 − 3
1
P3 2
= �� = �� = ���� = ����
� P4 3
�
2 7ms 15ms 23ms 43m 59ms 83m
�
7m
s 31ms
8
s
m s
67ms s
��1 ��2 ��3 8��
8ms ms 4
�
16ms 12ms 16ms
0
� ��2 ��3 ��4
�
36ms 16ms
1
� ��2 ��4
�
2
©Ahmed Operating 199
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue Scheduling
Now we add the concepts of varying arrival times and
preemption to the analysis
Process Arrival Time Burst
Time
P1 0 7
Using single-
P2 1 60
core processor
P3 2 20
P4 3 40
�
�0
�
�1
©Ahmed
� Operating 201
Hagag �2 Systems
Scheduling Algorithms
�
5. Multilevel Queue �
SchedulingProcess Arrival Time Burst 0
�
Time
1 �
P 0 7
1
P2 1 60 �
P3 2 20 �
2
P4 3 40
7
7m ms
s
� �
� �1
�
0
�1
�
©Ahmed � Operating 202
Hagag 2 Systems
Scheduling Algorithms
�
5. Multilevel Queue �
SchedulingProcess Arrival Time Burst 0
�
Time
1 �
P 0 7
1
P2 1 60 �
P3 2 20 �
2
P4 3 40
7
7m ms
s
� �
� �1
�
0
�1
�
©Ahmed � Operating 203
Hagag 2 Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProcess Arrival Time Burst
Time
P1 0 7
P2 1 60 52
P3 2 20
P4 3 40
15m
s
7ms
� �� 7
8ms 1
ms
�
�
0 ��2
�1
�
©Ahmed � Operating 204
Hagag 2 Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProcess Arrival Time Burst
Time
P1 0 7
P2 1 60 52
P3 2 20 12
P4 3 40
15ms
7ms 23m
7ms
� �� s
8ms 1 ��2
� ��
�
0 3
�1
�
©Ahmed � Operating 205
Hagag 2 Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProces Arrival Time Burst
s Time 0 7
P1 P2 1 60
P3 P4 2
52
3
20
15ms 3
1ms 7ms 12
8 40
8 23ms
7
ms ms
� �� �� �
ms
1 2
� � �8� 32
ms
�
0 3 4
�1
�
©Ahmed � Operating 206
Hagag 2 Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProces Arrival Time Burst
s Time 0 7
P1 P2 1 60 5
P3 P4 2 2 3
6
3
20 1
15ms 31ms 2
7ms 23m 47m 40 3
s
7ms 8ms s 2
� �� 8ms
�� �
� � 1 �8�
2
16ms
ms
� 3
0 4
��2
�
�
1
�
©Ahmed 2 Operating 207
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProces Arrival Time Burst
s Time 0 7
P1 P2 1 60 5
P3 P4 2 2 3
6
3
20 1
15ms 31ms 59ms 2
7ms 23m 47m 40 3
s
7ms 8ms s 2
� �� 8ms
�� �
� � 1 �8�
2
16ms 12ms
ms
� 3
0 4
��2 ��3
�
�
1
�
©Ahmed 2 Operating 208
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProces Arrival Time Burst
s Time 0 7
P1 P2 1 60 5
P3 P4 2 2 3
6
3
20 1
15ms 31ms 59ms 2
7ms 23m 47m 40 3
s
7ms 8ms s 2
� �� 8ms
�� �
� � 1 �8�
2
16ms 12ms
ms
� 3
0 4
��2 ��3
�
�
1
�
©Ahmed 2 Operating 209
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProces Arrival Time Burst
s Time 0 7
P1 P2 1 60 5
P3 P4 2 2 3
6
3
20 1
15ms 31ms 59ms 2
7ms 23m 47m 75 40
m 3
s
7ms 8ms s s 2 1
� �� 8ms
�� � 6
� � 1 �8�
2
16ms 12ms 16ms
ms
� 3
0 4
��2 ��3 ��4
�
�
1
�
©Ahmed 2 Operating 210
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProces Arrival Time Burst
s Time 0 7
P1 P2 1 60 5
P3 P4 2 2 3
6
3
20 1
15ms 31ms 59ms 2
7ms 23m 47m 75 40
m 3 111m
s
7ms 8ms s s 2 1 s
� �� 8ms
�� � 6
� � 1 �8�
2
16ms 12ms 16ms
ms
� 3
0 4
��2 ��3 ��4
� 36ms
�
1 ��2
�
©Ahmed 2 Operating 211
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProces Arrival Time Burst
s Time 0 7
P1 P2 1 60 5
P3 P4 2 2 3
6
3
20 1
15ms 31ms 59ms 2
7ms 23m 47m 75 40
m 3 111m
s
7ms 8ms s s 2 1 s
� �� 8ms
�� � 6
� � 1 �8�
2
16ms 12ms 16ms
ms
� 3
0 4
��2 ��3 ��4
� 36ms
�
1 ��2
�
©Ahmed 2 Operating 212
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProces Arrival Time Burst
s Time 0 7
P1 P2 1 60 5
P3 P4 2 2 3
6
3
20 1
15ms 31ms 59ms 2
7ms 23m 47m 75 40
m 3 111ms
s 8ms s s 2 1
� ��
7ms
8ms
�� � 6 127ms
� � 1 �8�
2
16ms 12ms 16ms
ms
� 3
0 4
��2 ��3 ��4
� 36ms 16ms
�
1 ��2 ��4
�
©Ahmed 2 Operating 213
Hagag Systems
Scheduling Algorithms
5. Multilevel Queue
SchedulingProces Arrival Time Burst
s Time 0 7
P1 P2 1 60 5
P3 P4 2 2 3
6
3
20 1
15ms 31ms 59ms 2
7ms 23m 47m 75 40
m 3 111ms
s 8ms s s 2 1
� ��
7ms
8ms
�� � 6 127ms
� � 1 �8�
2
16ms 12ms 16ms
ms
� 3
0 4
��2 ��3 ��4
� 36ms 16ms
�
1 ��2 ��4
�
©Ahmed 2 Operating 214
Hagag Systems
Scheduling Algorithms
Turnaround Time
5. Multilevel Queue ���� ���� ���� ����
SchedulingProces Arrival Time Burst 7−0 67 − 1 43 − 2 83 − 3
s Time 0 7 = �� = 66 = 41 = 80
P1 P2 1 60 5
P3 P4 2 2 3
6
3
20 1
15ms 31ms 59ms 2
7ms 23m 47m 75 40
m 3 111ms
s 8ms s s 2 1
� ��
7ms
8ms
�� � 6 127ms
� � 1 �8�
2
16ms 12ms 16ms
ms
� 3
0 4
��2 ��3 ��4
� 36ms 16ms
�
1 ��2 ��4
�
©Ahmed 2 Operating 215
Hagag Systems
Scheduling Algorithms
Waiting Time
5. Multilevel Queue ���� ���� ���� ����
SchedulingProces Arrival Time Burst 0 7-1 15+8-2 23+12+8- 3
s Time 0 7
P1 P2 1 60 5 =0 = 6 = 21 = 40
P3 P4 2 2 3
6
3
20 1
15ms 31ms 59ms 2
7ms 23m 47m 75 40
m 3 111ms
s 8ms s s 2 1
� ��
7ms
8ms
�� � 6 127ms
� � 1 �8�
2
16ms 12ms 16ms
ms
� 3
0 4
��2 ��3 ��4
� 36ms 16ms
�
1 ��2 ��4
�
©Ahmed 2 Operating 216
Hagag Systems
Scheduling Algorithms
Response Time
5. Multilevel Queue ���� ���� ���� ����
SchedulingProces Arrival Time Burst
s 7−0 7−1 15 − 2 23 − 3
Time 0 7
P1 P2 = �� =6 = 13 = ����
1 60 5 ��
P3 P4 2 2 3
6
3
20 1
15ms 31ms 59ms 2
7ms 23m 47m 75 40
m 3 111ms
s 8ms s s 2 1
� ��
7ms
8ms
�� � 6 127ms
� � 1 �8�
2
16ms 12ms 16ms
ms
� 3
0 4
��2 ��3 ��4
� 36ms 16ms
�
1 ��2 ��4
�
©Ahmed 2 Operating 217
Hagag Systems