0% found this document useful (0 votes)
13 views

Chapter 2,3 Extra

The document discusses two types of priority scheduling: preemptive and non-preemptive, highlighting how preemptive scheduling allows higher priority processes to interrupt currently running processes. It also defines deadlock, its causes, and methods for prevention, avoidance, and detection, emphasizing the importance of resource management to prevent processes from getting stuck. Various strategies such as mutual exclusion, hold and wait, no preemption, and circular wait are outlined to handle deadlocks effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Chapter 2,3 Extra

The document discusses two types of priority scheduling: preemptive and non-preemptive, highlighting how preemptive scheduling allows higher priority processes to interrupt currently running processes. It also defines deadlock, its causes, and methods for prevention, avoidance, and detection, emphasizing the importance of resource management to prevent processes from getting stuck. Various strategies such as mutual exclusion, hold and wait, no preemption, and circular wait are outlined to handle deadlocks effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Chapter 2

 Priority base preemptive


In Preemptive Priority Scheduling, at the time of arrival of a process in the ready
queue, its Priority is compared with the priority of the other processes present in
the ready queue as well as with the one which is being executed by the CPU at that
point of time. The One with the highest priority among all the available processes
will be given the CPU next.

The difference between preemptive priority scheduling and non preemptive


priority scheduling is that, in the preemptive priority scheduling, the job which is
being executed can be stopped at the arrival of a higher priority job.

Once all the jobs get available in the ready queue, the algorithm will behave as
non-preemptive priority scheduling, which means the job scheduled will run till the
completion and no preemption will be done.

 Priority base non-preemptive


In the Non Preemptive Priority scheduling, The Processes are scheduled according
to the priority number assigned to them. Once the process gets scheduled, it will
run till the completion. Generally, the lower the priority number, the higher is the
priority of the process. The people might get confused with the priority numbers,
hence in the GATE, there clearly mention which one is the highest priority and
which one is the lowest one.

Chapter 3

 Deadlocks:Definition

Deadlock is a situation in computing where two or more processes are unable to


proceed because each is waiting for the other to release resources. Key concepts
include mutual exclusion, resource holding, circular wait, and no preemption.
Consider an example when two trains are coming towards each other on the same
track and there is only one track, none of the trains can move once they are in
front of each other. This is a practical example of deadlock.
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.

 Deadlock Prevention

Deadlock Prevention and Avoidance is the one of the methods for handling
deadlock.
In deadlock prevention the aim is to not let fulfill one of the required condition of
the deadlock. This can be done by this method:

(i) Mutual Exclusion

We only use the Lock for the non-shareable resources and if the resource is
shareable (like read only file) then we not use the locks here. That ensure that in
case of shareable resource , multiple process can access it at same time.
Problem- Here the problem is that we can only do it in case of shareable
resources but in case of no-share-able resources like printer , we have to use
Mutual exclusion.

(ii) Hold and Wait

To ensure that Hold and wait never occurs in the system, we must guarantee
that whenever process request for resource , it does not hold any other resources.
we can provide the all resources to the process that is required for its execution
before starting its execution .
For example if there are three resource that is required by a process and we
have given all that resource before starting execution of process then there might
be a situation that initially we required only two resource and after one hour we
want third resources and this will cause starvation for the another process that
wants this resources and in that waiting time that resource can allocated to other
process and complete their execution.

We can ensure that when a process request for any resources that time the process
does not hold any other resources.
Ex- Let there are three resources DVD, File and Printer . First the process request
for DVD and File for the copying data into the file and let suppose it is going to
take 1 hour and after it the process free all resources then again request for File
and Printer to print that file.

(iii) No Preemption

If a process is holding some resource and requestion other resources that are
acquired and these resource are not available immediately then the resources that
current process is holding are preempted. After some time process again request
for the old resources and other required resources to re-start.

For example – Process p1 have resource r1 and requesting for r2 that is hold by
process p2. then process p1 preempt r1 and after some time it try to restart by
requesting both r1 and r2 resources.

(iv) Circular Wait:

To remove the circular wait in system we can give the ordering of resources in
which a process needs to acquire.
Ex: If there are process p1 and p2 and resources r1 and r2 then we can fix the
resource acquiring order like the process first need to acquire resource r1 and
then resource r2. So the process that acquired r1 will be allowed to acquire r2 ,
other process needs to wait until r1 is free.
This is the Deadlock prevention methods but practically only fourth method is
used as all other three condition removal method have some disadvantages with
them.

 Deadlock Avoidance
Avoidance is kind of futuristic. By using the strategy of “Avoidance”, we have to
make an assumption. We need to ensure that all information about resources that
the process will need is known to us before the execution of the process. We use
Banker’s algorithm to avoid deadlock.
In prevention and avoidance, we get the correctness of data but performance
decreases.

 Deadlock Detection
This approach let the processes fall in deadlock and then periodically check
whether deadlock occur in the system or not. If it occurs then it applies some of the
recovery methods to the system to get rid of deadlock.

Deadlock detection is a process in computing where the system checks if there


are any sets of processes that are stuck waiting for each other indefinitely,
preventing them from moving forward. In simple words, deadlock detection is the
process of finding out whether any process are stuck in loop or not. There are
several algorithms like;
 Resource Allocation Graph
 Banker’s Algorithm
These algorithms helps in detection of deadlock in Operating System.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy