Professional Documents
Culture Documents
Research, Indore
www.acropolis.in
Operating System
By: Nupur Agrawal
What is a Program
❖A program is a piece of code which may be a single line or millions of
lines. A computer program is usually written by a computer
programmer in a programming language.
❖A computer program is a collection of instructions that performs a
specific task when executed by a computer. When we compare a
program with a process, we can conclude that a process is a dynamic
instance of a computer program.
❖Eaxmple- a C program or Java Program
18 March 2024 25
Preemptive Scheduling Non-preemptive Scheduling
Description Operating system can interrupt processes Processes continue execution until
and allocate CPU to others. completion or voluntary release.
Interruption Processes can be interrupted during Processes are not interrupted once they
execution. start executing.
CPU Allocation CPU can be allocated to higher-priority Processes execute until completion,
processes if available. regardless of priorities.
Fairness Ensures fair resource allocation and Simplifies scheduling but may lead to
responsiveness. lower system responsiveness.
Examples Round Robin, Shortest Remaining Time First First-Come, First-Served (FCFS), Shortest
(SRTF), Priority Scheduling Job Next (SJN/SJF)
18 March 2024 26
First Come First Serve (FCFS)
❖ In the "First come first serve" scheduling algorithm, as the name suggests,
the process which arrives first, gets executed first, or we can say that the
process which requests the CPU first, gets the CPU allocated first.
❖ First Come First Serve, is just like FIFO(First in First out) Queue data
structure, where the data element which is added to the queue first, is the
one who leaves the queue first.
❖ This is used in Batch Systems.
❖ It's easy to understand and implement programmatically, using a Queue
data structure, where a new process enters through the tail of the queue,
and the scheduler selects process from the head of the queue.
❖ A perfect real life example of FCFS scheduling is buying tickets at ticket
counter.
18 March 2024 27
Advantages of FCFS
❖Simple
❖Easy
❖First come, First serve
18 March 2024 28
Disadvantages of FCFS
❖The scheduling method is non preemptive, the process will run to the
completion.
❖Due to the non-preemptive nature of the algorithm, the problem of
starvation may occur.
❖Although it is easy to implement, but it is poor in performance since
the average waiting time is higher as compare to other scheduling
algorithms.
18 March 2024 29
18 March 2024 30
Implementation
❖Input the number of process with their burst time.
❖Find Waiting time(WT) for all the process.
❖WT[i] = BT[i-1] +WT[i-1]
❖Find turn around time
TAT=WT+BT ( for a the process)
❖Find average WT
AWT=total WT/Total no. of process.
❖Find average TAT
avg TAT = total TAT/ total no. of process
P1 0 5
P2 1 3
P3 2 8
P4 3 6