The Institute of Management Sciences, Lahore: Assignment #2
The Institute of Management Sciences, Lahore: Assignment #2
Semester Fall-2022
BSCS(HONS)
ASSIGNMENT #2
CPU/Process Scheduling and Algorithm
Scheduling Objectives:
Preemptive Scheduling:
Non-Preemptive Scheduling:
Scheduling Criteria:
There are several different criteria to consider when trying to select the "best"
scheduling algorithm for a particular situation and environment, including:
Arrival Time: Time at which the process arrives in the ready queue.
Turn Around Time: Time Difference between completion time and arrival time.
Turn Around Time = Completion Time – Arrival Time
Waiting Time(W.T): Time Difference between turnaround time and burst time.
Waiting Time = Turn around Time – Burst Time.
Types of Scheduling Algorithm
In FCFS Scheduling
● The process which arrives first in the ready queue is firstly assigned the
CPU.
● In case of a tie, a process with a smaller process id is executed first.
● It is always non-preemptive in nature.
● Jobs are executed on a first come, first serve basis.
● It is a non-preemptive, preemptive scheduling algorithm.
● Easy to understand and implement.
● Its implementation is based on the FIFO queue.
● Poor in performance as average wait time is high.
● Processes which have the shortest burst time are scheduled first.
● If two processes have the same bust time, then FCFS is used to break the tie.
● This is a non-pre-emptive, preemptive scheduling algorithm.
● Best approach to minimize waiting time.
● Easy to implement in Batch systems where required CPU time is known in
advance.
● Impossible to implement in interactive systems where required CPU time is
not known.
● The processor should know in advance how much time the process will take.
● CPU is assigned to the process on the basis of FCFS for a fixed amount of
time.
● This fixed amount of time is called a time quantum or time slice.
● After the time quantum expires, the running process is preempted and sent to
the ready queue.
● Then, the processor is assigned to the next arriving process.
● It is always preemptive in nature.
PROCESS SCHEDULING ALGORITHM NUMERICAL PROBLEMS
EXAMPLES
1. First Come First Serve (FCFS):
2. Shortest Job First (SJF):
3. Shortest Remaining Time First (SRTF):