Professional Documents
Culture Documents
unit-2 os 2024
unit-2 os 2024
unit-2 os 2024
• Simple
• Easy
• First come, First served
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.
2.Shortest Job First (SJF) Scheduling
• Maximum throughput
• Minimum average waiting and turnaround time
Disadvantages of SJF
• May suffer with the problem of starvation
• It is not implementable because the exact Burst time for a
process can't be known in advance.
3.Priority scheduling
• Priority cpu scheduling algorithm is preemptive and non
preemptive algorithm. it is one of the most common
scheduling algorithm in batch system.
• A priority is associated with each process and the cpu is
allocated to the process with the highest priority.
• This scheduling algorithm cpu select higher priority process
first.
• if the priority of two process is same then FCFS scheduling
algorithm is applied for solving problem.
• A SJF algorithm is a special case of a priority scheduling
algorithm with priority(p) being proportional to 1/p
4.Round Robin Scheduling
• Round Robin scheduling each ready task runs turn by only in a
cyclic queue for a limited time slice. This algorithm also offer
starvation free execution of process.
• Round-robin scheduling is designed for timesharing system.
• It is similar to the FCFS scheduling, but preemptive is added
to switch between processes.
• A time quantum is typically 10 to 100 milliseconds.
• The ready queue is implemented in FIFO manner.
• Round Robin only preemptive algorithm apply a for
scheduling.
Multiple Processor Scheduling
• In multiple-processor scheduling multiple CPU’S are available
• Load sharing becomes possible as distributed among these
available processor
• Multiple processor scheduling is more complex as compared
to single processor scheduling
• Multiprocessor systems may be heterogeneous (different
kinds of CPUs) or homogenous (the same CPU). There may
be special scheduling constraints, such as devices connected
via a private bus to only one CPU.
• Multi processor scheduling is of two types
• i)Asymmetric scheduling
• ii) symmetric scheduling
i)Asymmetric scheduling
• fork()
• Processes generate clones of themselves using
the fork() system call.
• It is one of the most common ways to create processes in
operating systems.
• When a parent process spawns a child process, execution of
the parent process is interrupted until the child process
completes.
• Once the child process has completed its execution, control is
returned to the parent process.
exit()
Deadlock
• Every process needs some resources to complete its execution.
However, the resource is granted in a sequential order.
• Deadlock is a situation where a set of processes are blocked
because each process is holding a resource and waiting for another
resource acquired by some other process.
• The process requests for some resource.
• OS grant the resource if it is available otherwise let the process
waits.
• The process uses it and release on the completion.
• A Deadlock is a situation where each of the computer process waits
for a resource which is being assigned to some another process.
•
Deadlock – System model
• Let us assume that there are three processes P1, P2 and P3.
There are three different resources R1, R2 and R3.
• R1 is assigned to P1, R2 is assigned to P2 and R3 is assigned
to P3.
• After some time, P1 demands for R1 which is being used by
P2.
• P1 halts its execution since it can't complete without R2.
• P2 also demands for R3 which is being used by P3.
• P2 also stops its execution because it can't continue without
R3.
• P3 also demands for R1 which is being used by P1 therefore
P3 also stops its execution.
In this scenario, a cycle is being formed among the three processes. None of the process is progressing and they are all waiting. The computer
becomes unresponsive since all the processes got blocked.