0% found this document useful (0 votes)
10 views14 pages

Uniprocessor Scheduling Schemes

The document discusses processor scheduling, outlining three types: long-term, medium-term, and short-term scheduling. It details various scheduling algorithms such as First-Come-First-Served, Round-Robin, Shortest Process Next, Shortest Remaining Time, and Highest Response Ratio Next, along with their respective criteria and examples. Additionally, it covers decision modes and other scheduling schemes like priority and feedback mechanisms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views14 pages

Uniprocessor Scheduling Schemes

The document discusses processor scheduling, outlining three types: long-term, medium-term, and short-term scheduling. It details various scheduling algorithms such as First-Come-First-Served, Round-Robin, Shortest Process Next, Shortest Remaining Time, and Highest Response Ratio Next, along with their respective criteria and examples. Additionally, it covers decision modes and other scheduling schemes like priority and feedback mechanisms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 14

UNIPROCESSOR SCHEDULING:

PRINCIPLES AND ALGORITHMS


Types of Processor Scheduling
There are three (3) types of processor scheduling.
These are:
• Long-term scheduling
• Medium-term scheduling
• Short-term scheduling
Types of Processor Scheduling, contd.
• Long-term scheduling. – This is a decision to add a
new process to the set of processes that are currently
active. The long-term scheduler determines which
programs are admitted to the system for processing. The
criteria used may include priority, expected execution
time, I/O requirements, and which I/O resources are to
be requested.
• Medium-term scheduling – This is the decision
whether to add a process to those that are partially or
fully in main memory, and therefore available for
execution.
• Short-term scheduling – This is the decision as to
which available process will be executed by the
processor next.
Five-State Process Model:
Scheduling & Process State Transitions

New

Long-term Long-term
scheduling scheduling

Ready/ Running Exit


Ready
Suspend Medium- Short-term
term scheduling scheduling

Blocked/
Blocked
Suspend
Medium-term
scheduling
Scheduling Criteria
1. User Oriented scheduling criteria
• Turnaround time This is the interval of time between the
submission of a process and its completion. It includes actual
execution time plus time spent waiting for resources, including
the processor.
Turnaround Time = Finish Time – Arrival time
• Response time This is the time from the submission of a
request until the response begins to be received.
• Waiting time: is the sum of the periods spent waiting in the
ready queue.
2. System Oriented scheduling criteria
• Throughput This is the number of processes completed per unit
of time. It is influenced the average length of a process and the
scheduling policy.
• Processor utilization This is the percentage of time that the
processor is busy.
• Enforcing priorities When processes are assigned priorities,
processes with higher priorities are executed before those with
lower priorities.
Decision modes
The decision mode specifies the time instants at
which the selection function is exercised. There are
two general categories:
– Nonpreemptive: In this case, once a process is
in the Running state, it continues to execute until
(a) it terminates or
(b) it blocks itself to wait for I/O or to request
some operating system service.
– Preemptive: Here, the currently running
process may be interrupted and moved to the
Ready state by the operating system. The
decision to preempt may be performed when a
new process arrives; when an interrupt occurs
that places a blocked process in the Ready state;
or periodically, based on a clock interrupt.
Scheduling Algorithms
Example:
Suppose 5 processes A, B, C, D and E arrive at the times
indicated, and each of them is executed for the amount of time
specified in the table below:
Process Arrival Time Service Time (Ts)
A 0 3
B 2 6
C 4 4
D 6 5
E 8 2
For each of the scheduling schemes we shall cover in this
lecture, we shall determine the following:
(i). the finish time for each process.
(ii). the turnaround time for each process.
(iii). the normalized turnaround time for each process.
(iv). the mean turnaround time for all processes.
(v). the mean normalized turnaround time for all
processes.
Scheduling schemes that we will cover are:
1. First-Come-First-Served (FCFS): A simple
queuing scheme. Also referred to as first-in-
first-out (FIFO).
2. Round-Robin (RR): Scheduling is done on a
preemptive-time-quantum basis.
3. Shortest Process Next (SPN): A non-
preemptive scheme in which the process with
the shortest expected processing time is
selected next.
4. Shortest Remaining Time (SRT): A
preemptive scheme in which the process that
has the shortest expected remaining processing
time is executed next.
5. Highest Response Ratio Next (HRRN): Uses
a response ratio formula to determine the nest
process to execute.
1. First-Come-First-Served (FCFS):
[Also known as first-in-first-out (FIFO) ]
As each process becomes ready, it joins the ready queue. When
the currently running process ceases to execute, the process tha
has been in the ready queue the longest is selected for running.
Example: : Process A B C D E
Arrival Time 0 2 4 6 8
Service Time (Ts) 3 6 4 5 2

First-come-first-served (FCFS)
Process A B C D E Mean
(i). Finish Time 3 9 13 18 20
(ii) & (iv).Turnaround Time (Tr) 3 7 9 12 12 8.60

(iii) & (v). Normalized turnaround time:


(Tr/Ts) 1.00 1.17 2.25 2.40 6.00 2.56

NB: Turnaround Time (Tr)=Total time a process spend in the system


i.e. Tr = Waiting time + Service times
OR: Tr = Finish time – Arrival time
2. Round-Robin (RR)
This scheduling scheme uses preemption based on a clock
interrupt that is generated at periodic intervals. When the
interrupt occurs, the currently running process is placed
in the ready queue, and the next ready job is selected on
a FCFS basis. This technique is also known as time
slicing, because each process is given a slice of time
before being preempted
Example: : Process A B C D E
Arrival Time 0 2 4 6 8
Service Time (Ts) 3 6 4 5 2

Round-Robin (RR) q = 4
Process A B C D E Mean
(i). Finish Time 3 17 11 20 19
(ii) & (iv). Turnaround Time (Tr) 3 15 7 14 11 10.00
(iii) & (v). Normalized turnaround time (Tr/Ts):
1.00 2.5 1.75 2.80 5.50 2.71
3. Shortest Process (time) Next (SPN):
This scheduling scheme/algorithm is a non- preemptive policy in
which the process with the shortest expected processing time is
selected next. Thus, a short process will jump to the head of the
queue past longer jobs.

Example: : Process A B C D E
Arrival Time 0 2 4 6 8
Service Time (Ts) 3 6 4 5 2

Shortest process next (SPN)


Process A B C D E Mean
(i). Finish Time 3 9 15 20 11
(ii) &(iv). Turnaround Time (Tr) 3 7 11 14 3 7.60

(iii) & (v). Normalized turnaround time (Tr/Ts):


1.00 1.17 2.75 2.80 1.50 1.84
4. Shortest Remaining Time (SRT):
The SRT policy is a preemptive version of Shortest Process
Next (SPN). In this case, the scheduler always chooses the
process that has the shortest expected remaining processing
time. When a new process joins the ready queue, it may in fact
have a shorter remaining time than the currently running
process. Accordingly, the scheduler may preempt the current
process when such a new process becomes ready.

Example: : Process A B C D E
Arrival Time 0 2 4 6 8
Service Time (Ts) 3 6 4 5 2
SRT
Process A B C D E
Mean
(i). Finish Time 3 15 8 20 10
(ii) & (iv). Turnaround Time (Tr) 3 13 4 14 2
7.20
(iii) & (v). Normalized turnaround time Tr/Ts:
1.00 2.17 1.00 2.80 1.00
5. Highest Response Ratio Next (HRRN):
This scheduling scheme uses the following algorithm: When the
current process completes or is blocked, choose the ready
process with the greatest value of R from the formula:
R = (w + s)/ s
where
R = response ratio
w = time spent waiting for the processor
s = expected service time
Example: : Process A B C D E
Arrival Time 0 2 4 6 8
Service Time (Ts) 3 6 4 5 2

Highest response ratio next (HRRN)


Process A B C D E
Mean
(i). Finish Time 3 9 13 20 15
(ii) & (iv). Turnaround Time (Tr) 3 7 9 14 7 8.00
(iii) & (v). Normalized turnaround time (Tr/Ts):
1.00 1.17 2.25 2.80 3.5 2.14
Other Scheduling schemes in common use
a. Priority: Here, the process with highest priority is allocated
first, followed by the next higher priority process, etc

b. Feedback: For this scheduling scheme, scheduling is done on


a preemptive (at time quantum) basis using a dynamic priority
mechanism. When a process first enters the system, it is
placed in the Ready queue, RQ0.
• After its first preemption, when it returns to the Ready state,
it is placed in RQ1.
• Each subsequent time that it is preempted, it is demoted to
the next lower-priority queue i.e.RQ2, RQ3, etc.
• A short process (unlike a long one) will complete quickly,
without migrating very far down the hierarchy of ready
queues. Thus, newer, shorter processes are favoured over
older, longer processes.
• Within each queue, except the lowest-priority (LP) queue, a
simple FCFS (or FIFO) mechanism is used.
• Once in the lowest-priority queue, a process cannot go
lower, but is returned to this queue repeatedly until it
completes execution. Thus, RR is used for this LP queue.

You might also like