OSY_4th Unit Notes
OSY_4th Unit Notes
Advantages of FCFS:
1. FCFS is easy to implement and understand.
2. It promotes fairness by serving processes in arrival order.
3. The algorithm prevents starvation, ensuring all processes run.
4. The execution order is predictable, aiding performance analysis.
Disadvantages of FCFS:
1. It can cause the convoy effect, leading to inefficiencies.
2. Average waiting times are often high, especially with long processes.
3. FCFS is non-preemptive, so processes cannot be interrupted.
4. It is not suitable for time-sharing systems needing quick responses.
Example:
2] SJF Algorithm:
▪ Process which has 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, pre-emptive 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 processer should know in advance how much time process will take.
▪ Pre-emptive mode of Shortest Job First is called as Shortest Remaining
Time First (SRTF)
Characteristics of SJF:
Example:
Example:
Advantages of SJF:
1. SJF minimizes average waiting time.
2. It optimizes turnaround time for arriving processes.
3. Shorter processes are prioritized, improving responsiveness.
4. The algorithm is simple to implement.
Disadvantages of SJF:
1. It can cause starvation for longer processes.
2. Estimating burst times accurately is difficult.
3. SJF is non-preemptive, preventing interruption of running processes.
4. It may struggle with mixed workloads of short and long processes.
3] Priority Scheduling:
▪ Priority scheduling is a non-preemptive algorithm and one of the most
common scheduling algorithms in batch systems.
▪ Each process is assigned a priority. Process with highest priority is to be
executed first and so on.
▪ Processes with same priority are executed on first come first served basis.
▪ Priority can be decided based on memory requirements, time requirements
or any other resource requirement
3. No Pre-emption:
The process which once scheduled will be executed till
the completion. No other process can be scheduled by the scheduler
meanwhile. In the diagram below, Process 2 cannot preempt Resource 1
from Process 1. It will only be released when Process 1 relinquishes it
voluntarily after its execution is complete.
4. Circular Wait:
All the processes must be waiting for the resources in a
cyclic manner so that the last process is waiting for the resource which is
being held by the first process. For example: Process 1 is allocated
Resource2 and it is requesting Resource 1. Similarly, Process 2 is allocated
Resource 1 and it is requesting Resource 2. This forms a circular wait loop.
Advantages of Deadlock:
1. Effective resource usage until resolved.
2. Simplifies resource management.
3. Maintains process consistency.
4. Allows prioritization of critical tasks.
Disadvantages of Deadlock:
1. Causes indefinite process blocking.
2. Increases system complexity.
3. Leads to resource starvation.
4. Difficult to identify and resolve.