Assignment No 4 Submitted To:. Sir Salman Butt
Assignment No 4 Submitted To:. Sir Salman Butt
Here every process will follow the system model which means the process
requests a resource if not allocated then wait otherwise it allocated will use the
resources and release it after use.
1. Deadlock ignorance:
It is the most popular method and it acts as if no deadlock and the user will
restart. As handling deadlock is expensive to be called of a lot of codes need to
be altered which will decrease the performance so for less critical jobs deadlock
are ignored. Ostrich algorithm is used in deadlock Ignorance. Used in windows,
Linux etc.
2. Deadlock prevention:
It means that we design such a system where there is no chance of having a
deadlock.
Mutual exclusion:
It can’t be resolved as it is the hardware property. For example, the printer
cannot be simultaneously shared by several processes. This is very difficult
because some resources are not sharable.
Hold and wait:
Hold and wait can be resolved using the conservative approach where a process
can start it and only if it has acquired all the resources.
Active approach:
Here the process acquires only requires resources but whenever a new resource
requires it must first release all the resources.
Wait time out:
Here there is a maximum time bound until which a process can wait for other
resources after which it must release the resources.
Circular wait:
In order to remove circular wait, we assign a number to every resource and the
process can request only in the increasing order otherwise the process must
release all the high number acquires resources and then make a fresh request.
No pre-emption:
In no pre-emption, we allow forceful pre-emption where a resource can be
forcefully pre-empted. The pre-empted resource is added to the list of resources
where the process is waiting. The new process can be restarted only when it
regains its old resources. Priority must be given to a process which is in waiting
for state.
3. Deadlock avoidance:
Here whenever a process enters into the system it must declare maximum
demand. To the deadlock problem before the deadlock occurs. This approach
employs an algorithm to access the possibility that deadlock would occur and not
act accordingly. If the necessary condition of deadlock is in place it is still
possible to avoid feedback by allocating resources carefully.
A deadlock avoidance algorithm dynamically examines the resources
allocation state to ensure that a circular wait condition case never exists. Where
the resources allocation state is defined by the of available and allocated
resources and the maximum demand of the process. There are 3 states of the
system
Safe state
When a system can allocate the resources to the process in such a way so that
they still avoid deadlock then the state is called safe state. When there is a safe
sequence exit then we can say that the system is in the safe state.
A sequence is in the safe state only if there exists a safe sequence. A sequence
of process P1, P2, Pn is a safe sequence for the current allocation state if for
each Pi the resources request that Pi can still make can be satisfied by currently
available resources pulls the resources held by all Pj with j<i.
2) Bankers’s algorithm
The resource allocation graph algorithms not applicable to the system with
multiple instances of the type of each resource. So for this system Banker’s
algorithm is used.
Here whenever a process enters into the system it must declare maximum
demand possible.
At runtime, we maintain some data structure like current allocation, current need,
current available etc. Whenever a process requests some resources we first
check whether the system is in a safe state or not meaning if every process
requires maximum resources then is there ant sequence in which request can be
entertaining if yes then request is allocated otherwise rejected.
Safety algorithm
This algorithm is used to find whether system is in safe state or not we can find
A B C D( 6 5 7 6) - A B C D( 3 4 6 4
Available resources A B C D( 3 1 1 2)
Then we check whether the system is in deadlock or not and find the safe
sequence of process.
P1 can be satisfied
P2 can be satisfied
Process termination:
Deadlock can be eliminated by aborting a process. Abort all deadlock process.
Abort is processed at a time until the deadlock cycle is eliminated. This can help
to recover the system from file deadlock.
Resources preemption:
To eliminate deadlock using resources preemption, we prompt the same
resources pas processes and give these resources to another process until the
deadlock cycle is broken.
Here a process is partially rollback until the last checkpoint or and hen detection
algorithm is executed.