Professional Documents
Culture Documents
Sheet 5 o PDF
Sheet 5 o PDF
FCFS Scheduling in OS
It is the simple CPU scheduling algorithm. The criteria of this algorithm are the
process that requests the CPU first or the process which enters ready queue first,
served first. If a process requests then it is loaded by short-term scheduler into the
ready queue. The process is then connected to the CPU by a dispatcher for
execution. It is called the FCFS scheduling in operating system.
The main disadvantage of this algorithm is aging. Due to this problem, big jobs
have to wait for the CPU for a long time.
Q1:
If the new process having the least CPU burst time, the scheduler selects that job
and connect to the CPU, otherwise, continue in the old process.
First of all, we have to find the waiting time for each process.
Waiting Time of process
P1 = 0ms
P2 = (3 - 2) + (10 - 4) = 7ms
P3 = (4 - 4) = 0ms
P4 = (15 - 6) = 9ms
P5 = (8 - 8) = 0ms
Therefore, Average Waiting Time = (0 + 7 + 0 + 9 + 0) / 5 = 3.2ms
Advantage
For finding Average Waiting Time, we have to find out the waiting time of each
process.
Waiting Time of
P1 = 0 + (15 - 5) + (24 - 20) = 14ms
P2 = 5 + (20 - 10) = 15ms
P3 = 10 + (21 - 15) = 16ms
Therefore, Average Waiting Time = (14 + 15 + 16) / 3 = 15ms
The criteria of this algorithm in which the process having the smallest CPU burst
time, CPU is assigned to the process next, if two processes have the same CPU
burst time, FCFS is used to break the tie.
Advantage
It has least average waiting time, average turnaround time and average response
time.
Disadvantage
New processes added to the tail of the ready queue. The CPU scheduler picks the
first process from the ready queue, set a timer to interrupt after one time-quantum,
and dispatches the process.
If the process may have a CPU burst time is less than one time-quantum, then
process releases the CPU voluntarily. The scheduler will then proceed to the next
process in the ready queue.
Otherwise, if the CPU burst time of the concurrently running process is longer than
one time-quantum, then the process will be put at the tail of the ready queue. The
CPU scheduler will then select the next process.
Q2:
We will apply the same formula to find average waiting time in this problem. Here
arrival time is common to all processes(i.e., zero).
Waiting Time for
P1 = 3 - 0 = 3ms
P2 = 34 - 0 = 34ms
P3 = 18 - 0 = 18ms
P4 = 8 - 0 = 8ms
P5 = 0ms
Now, Average Waiting Time = (3 + 34 + 18 + 8 + 0) / 5 = 12.6ms
Priority Scheduling in OS
Generally, priorities are of two types. One is the internal priority, and the second is
the external priority. External priority means it is external to the operating system.
The CPU is allocated to process with the highest priority.
The priorities use some measurable quantities to compute the priority of a process.
For example, time limits, memory requirements, the number of open files, and the
ratio of average I/O burst to an average CPU burst have used in computing
priorities.
Disadvantage
The major problem with priority scheduling is starvation. Starvation means only
high priority processes are executing, but low priority jobs are waiting for the CPU
for a long time.
First of all, we have to find out the waiting time of each process.
Waiting Time of process
P1 = 3ms
P2 = 13ms
P3 = 25ms
P4 = 0ms
P5 = 9ms
Therefore, Average Waiting Time = (3 + 13 + 25 + 0 + 9) / 5 = 10ms