0% found this document useful (0 votes)
48 views4 pages

Scheduling Algorithm Tutorial: Average Times

This document presents a series of questions related to calculating average waiting times and turnaround times for different scheduling algorithms including FCFS, SJF, RR, and PQ. It provides examples of processes with varying arrival times, priorities, and required quanta. Learners are asked to apply the different scheduling algorithms to calculate metrics like average waiting time and turnaround time.

Uploaded by

DOUMBOUYA SIDIKI
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views4 pages

Scheduling Algorithm Tutorial: Average Times

This document presents a series of questions related to calculating average waiting times and turnaround times for different scheduling algorithms including FCFS, SJF, RR, and PQ. It provides examples of processes with varying arrival times, priorities, and required quanta. Learners are asked to apply the different scheduling algorithms to calculate metrics like average waiting time and turnaround time.

Uploaded by

DOUMBOUYA SIDIKI
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

TUTORIAL 02 – SCHEDULING ALGORITHM

SUBJECT : BIT2CC063 Operating System


SUBJECT LECTURER : Ms. Athirah
STUDENT NAME :
STUDENT ID :

QUESTION

1. Processes A, B and C arrive in that order. A has priority 3 and requires 8 quanta, B
has priority 1 and takes 10 quanta and C has priority 3 and requires 6 quanta.
Calculate the average Waiting Time and Turn Around Time if the scheduling
mechanism used is:
(a) FCFS
(b) SJF
(c) RR
(d) PQ

Assume that the time for a context switch can be ignored.

2. Processes W, X, Y and Z arrive in that order. W has priority 1 and requires 7 quanta,
X has priority 3 and takes 9 quanta, Y has priority 2 and requires 5 quanta and Z has
priority 3 and requires 6 quanta. Calculate the Average Waiting Time and Turn
Around Time if the scheduling mechanism used is:
(a) FCFS
(b) SJF
(c) RR
(d) PQ

Assume that the time for a context switch can be ignored.

3. Processes P, Q, R, S and T arrive in that order. P has priority 2 and requires 6


quanta, Q has priority 3 and takes 8 quanta, R has priority 1 and requires 3 quanta, S
has priority 1 and requires 7 quanta and T has priority 2 and requires 6 quanta.
Calculate the Average Waiting Time and Turn Around Time if the scheduling
mechanism used is:
(a) FCFS
(b) SJF
(c) RR
(d) PQ

Assume that the time for a context switch can be ignored.


4. An operating system has two process priority levels, 1 and 2. Three new processes,
X, Y and Z arrive at the same time in that order with the following characteristics:

Process X Y Z
Quanta Required 4 8 10
Priority 1 2 1

Calculate the Average Waiting Time and Average Turn-Around Time if:
(a) normal Round Robin scheduling is used.
(b) modified Round Robin scheduling which gives priority 1 processes a
double quantum and priority 2 processes a single quantum whenever they
are scheduled.

Assume that the time for a context switch can be ignored.

5. An operating system has two process priority levels, 1 and 2. Three new processes,
A, B and C, arrive at the same time in that order with the following characteristics:

Process A B C
Quanta Required 20 30 40
Priority 1 1 2

Calculate the Average Waiting Time and Average Turn-Around Time if:
(a) normal Round Robin scheduling is used.
(b) modified Round Robin scheduling which gives priority 1 processes a
double quantum and priority 2 processes a single quantum whenever they
are scheduled.
(c) What advantages or disadvantages has the algorithms described in (b)
compared to Priority Queue (PQ) scheduling?

Assume that the time for a context switch can be ignored.

6. An operating system has two process priority levels, 1 and 2. Four new processes, A,
B, C and D arrive at the same time in that order with the following characteristics:

Process A B C D
Quanta Required 6 9 12 15
Priority 1 2 1 2

Calculate the Average Waiting Time and Average Turn-Around Time if:
(a) normal Round Robin scheduling is used.
(b) modified Round Robin scheduling which gives priority 1 processes a triple
quantum and priority 2 processes a single quantum whenever they are
scheduled.

Assume that the time for a context switch can be ignored.


7. An operating system has two process priority levels, 1 and 2. Three new processes,
P, Q and R arrive at the same time in that order with the following characteristics:

Process P Q R
Quanta Required 24 6 12
Priority 1 2 2

Calculate the Average Waiting Time and Average Turn-Around Time if:

(a) normal Round Robin scheduling is used.


(b) modified Round Robin scheduling which gives priority 1 processes a triple
quantum and priority 2 processes a double quantum whenever they are
scheduled.

Assume that the time for a context switch can be ignored.

8. Suppose that the following processes arrive for execution at the times indicated.
Each process will run for the amount of time listed. In answering the questions, use
non-preemptive scheduling and base all decision on the information you have at the
time the decision must be made:

Process Arrival time Burst time


P1 0.6 8
P2 0.4 4
P3 1.0 1
P4 0.2 3

(a) What is the average turnaround time for these processes with the FCFS
scheduling algorithm?

(b) What is the average turnaround time for these processes with the SJF
scheduling algorithm?

9. Consider the following set of processes, with the length of the CPU burst given in
millisecond:

Process Burst time Priority


P1 10 3
P2 1 1
P3 2 3
P4 1 4
P5 5 2

The processes are assumed to have arrived in the order P1, P2, P3, P4, P5 all at time 0.
(a) Draw four Gantt charts that illustrate the execution of these processes
using the following scheduling algorithms: FCFS, SJF, non-preemptive
priority (smaller priority number implies a high priority) and RR
(quantum =1).

(b) What is the turnaround time of each process for each of the scheduling
algorithms in part (a)?

(c) What is the waiting time of each process for each of these scheduling
algorithms?

(d) Which of the algorithms results in the minimum average waiting time
(over all processes)?

Common questions

Powered by AI

Non-preemptive scheduling leads to greater predictability since a process runs to completion, but potentially high turnaround time for short processes. Preemptive scheduling improves turnaround for shorter tasks by allowing interruption of currently executing tasks for more urgent processes, enhancing responsiveness but potentially causing more context-switching overhead .

Prioritization can lead to starvation if high-priority processes consistently occupy the CPU, delaying or neglecting lower-priority processes. Introducing aging, which gradually increases the priority of waiting processes, or setting execution limits for high-priority processes can prevent starvation .

Modified Round Robin scheduling, which assigns larger quanta to higher priority processes, improves efficiency by reducing context switches for those processes and ensuring they complete quicker. This method decreases wait times for high-priority tasks but can lead to increased waiting for lower-priority processes, impacting overall fairness compared to normal Round Robin .

In a First-Come, First-Served (FCFS) scheduling, processes are executed in the order they arrive, leading to potentially high waiting times, especially if a long process arrives first. Shortest Job First (SJF) scheduling, on the other hand, reduces average waiting time by executing the shortest processes first, minimizing delay for shorter processes .

In preemptive priority scheduling, processes with higher priority interrupt lower priority tasks, potentially reducing their waiting time dramatically. Non-preemptive scheduling waits for current tasks to finish, which can increase the waiting time for higher-priority tasks arriving during lower-priority task execution .

Smaller quanta in Round Robin scheduling increase system responsiveness and fairness by allowing frequent process switching. However, this also increases the overhead from context switching. Larger quanta reduce context switching costs but can lead to longer wait times for processes and reduce system responsiveness for users .

Priority Queue scheduling offers advantages in handling short, high-priority tasks efficiently by immediately addressing them regardless of their arrival time, reducing latency. Standard Round Robin treats all processes equally without regard to urgency, which could delay critical tasks when it circulates through all processes .

Normal Round Robin scheduling divides CPU time evenly among processes, leading to fair but potentially longer turnaround times. Priority Queue scheduling executes processes based on priority levels, potentially improving turnaround times for high-priority processes but may starve lower priority processes .

SJF optimizes scheduling efficiency by always selecting the shortest job to execute next, reducing average turnaround and waiting times, hence increasing throughput. However, it can suffer from the "starvation" problem for longer processes and requires precise knowledge of process burst times, which is not always available in dynamic systems .

With all processes arriving simultaneously, FCFS executes them in arrival order, leading to increasing turnaround times if long processes precede short ones. SJF prioritizes shorter burst times, reducing the average turnaround time significantly as shorter tasks complete faster and free resources sooner .

You might also like