Atharv OSY MP Final
Atharv OSY MP Final
Mrs.Wangikar V.S
DEPARTMENT OF INFORMATION TECHNOLOGY
NBA ACCREDIATED
AFFILIATED TO
M.S.B.T.E.
Evolution sheet for Micro Project
Marks out of 4
Marks out of 6 Total
for
for mars
Roll No Name of students performance
performance in out
in oral/
group activity of 10
Presentation
CERTIFICATE
is a bonafide work carried out by above students, under the guidance of Mrs.Wangikar V.S and it is
submitted towards the fulfillment of requirement of MSBTE, Mumbai for the award of Diploma in
Information Technology at SVERI’s COE (Polytechnic), Pandharpur during the academic year 2024-25.
(Mrs.Wangikar V.S)
Guide
(Mr. Bhandare P.S ) (Dr. Misal N. D.)
HOD Principal
Place: Pandharpur
Date:
`
Acknowledgement
“ Banker’s algorithm for deadlock detection” has been developed successfully with a
great contribution of four students in a period of two months. We like to appreciate their guidance,
encouragement and willingness since without their support the project would not have been a success.
We would like to give our heartfelt gratitude to Principal Dr. N.D. Misal Sir ,Guide Mrs.Wangikar V.S
Mam & HOD Mr. P. S. Bhandare Sir who is the supervisor of our project for helping and encouraging
us in many ways to make our project a success. We would never been able to finish our work without
great support and enthusiasm from friends and support from our family. We would like to thank the
department of Computer Engineering, for giving us permission to initiate this project and successfully
finishit.
`
Introduction
In an operating system, the CPU plays a more important role in executing processes and controlling the
flow of the computing smoothly. Deadlocks are the main problems for the operating system to tackle,
whenever a deadlock occurs execution of processes stops completely. To overcome (Solve) this deadlock
situation there are two algorithms one for avoidance and one for detection. In the further report, we are
going to see take look at how they are implemented with the help of examples.
`
An Operating System is basically a system program that controls the execution of application programs
and acts as an interface between applications and the computer hardware. It manages the computer
system resources to be used in an efficient manner.
This course enables one to learn the internal functioning of operating systems and will help in
identifying appropriate Operating Systems for given applications/tasks. This course is also a prerequisite
for the group of courses included in the 'Cloud Infrastructure Maintenance' Elective group.
`
Apply deadlock avoidance and safety algorithms to detect and avoid deadlocks.
Proposed methodology:-
We will concentrate on the materials we require, as well as the instructions, and sort it out in a
manner that will expedite the various duties of the team members.
Get details about the algorithms and how they are used to detect and avoid deadlock.
Solve the problems (examples) based on algorithms to detect and avoid deadlock.
Cross-check all the conclusions and answers.
Prepare a report on the topic.
Resources used:-
1. Literature Review:-
Deadlock is not the main hazard to the operating system. o Deadlocks don’t arise more often, the
frequency of deadlock occurrence is too less but whenever a deadlock occurs system’s execution stops
completely. Most systems don’t involve default codes for deadlock avoidance and detection in the
system because of deadlock’s rare occurrence and putting complex codes for deadlock avoidance and
detection does not significantly impact the speed of computing. To overcome this situation we can use
banker’s & Safety algorithms
We focused on the materials we needed, as well as the instructions, and sorted it out in a manner
that will expedite different responsibilities of the team members.
The gathered information about the algorithms and how they are used to detect and avoid
deadlock.
Prepared a report.
Process 4 7
C
Since only 7 (3+4) tape drives are currently on loan (allocated), two (2) tape drives are still available.
Process B can finish with only two additional tape drives.
Once Process B is done, it will release all 5 tape drives, making the number of available tape drives = 5.
With only three of these tape drives, either Process A or Process C may complete and release its tape
drives.
This means that there are two possible safe sequences: <Process B, Process A, Process C> and <Process B,
Process C, Process A>.
Thus, we say that this is a safe state.
Again assume we have nine tape drives. Consider whether or not the following states are safe or unsafe.
Process 2 5
B
Process 1 3
C
Since 8 (5+2+1) tape drives are currently on loan (allocated), only one tape drive is still available.
`
None of the three processes can complete with only one additional tape drive. This means that there are no
safe sequences possible.
Thus, we say that this is an unsafe state.
The number of available tape drives is reduced to one (1). No process can be granted enough tape
drives to complete.
This means that there will be no safe sequences possible, if we grant Process C's request.
Thus, granting this request will take us from a safe state to an unsafe state.
The resource allocation graph is the pictorial representation of the state of a system. As its name
suggests, the resource allocation graph is the complete information about all the processes which are
holding some resources or waiting for some resources. It also contains the information about all the
instances of all the resources whether they are available or being used by the processes.
In Resource allocation graph, the process is represented by a Circle while the Resource is represented
by a rectangle. Let's see the types of vertices and edges in detail.
`
Vertices are mainly of two types, resource and process.Each of them will be represented by a different
shape. Circle represents process while rectangle represents resource. A resource can have more than
one instance. Each instance will be represented by a dot inside the rectangle.
Example:-
Let'sconsider 3 processes P1, P2 and P3, and two types of resources R1 and R2. The resources are
having 1 instance each. According to the graph, R1 is being used by P1, P2 is holding R2 and waiting
for R1, P3 is waiting for R1 as well as R2.
The graph is deadlock free since no cycle is being formed in the graph.
`
int main()
running[i] = 1; counter++;
}
printf("\nEnternumberofresources:");scanf("%d"&resources);
{
`
scanf("%d", &maxres[i]);
scanf("%d", &Resources_Already_Having[i][j]);
scanf("%d", &Resources_Required[i][j]);
printf("\nTheClaimResourceis:");
printf("\t%d", maxres[i]);
printf("\t%d", Resources_Already_Having[i][j]);
}
`
printf("\n");
printf("\n");
for(j=0;j<resources;j++)
allocation[j] += Resources_Already_Having[i][j];
printf("\t%d", allocation[i]);
printf("\t%d", Resources_Available[i]);
}
`
printf("\n");
while (counter != 0)
safe = 0;
if (running[i])
Exection = 1;
Exection = 0; break;
if (Exection)
counter--; safe = 1;
Resources_Available[j] += Resources_Already_Having[i][j];
break;
}
`
if (!safe)
else
printf("\t%d", Resources_Available[i]);
printf("\n");
return 0;
}
`
Output:-
We got detailed information about CPU scheduling & algorithms, also the deadlock situation which
has four necessary conditions
`
· Mutual Exclusion
· Hold & Wait
· No-Preemption
· Circular Wait (if that all conditions hold simultaneously )
in the system then a deadlock situation can occur in the system. There are four ways we can face the
deadlock out of four we saw two methods one is deadlock avoidance and the second one is deadlock
detection. We also focused on other techniques of handling deadlocks
Advantages:-
1. It contains various resources that meet the requirements of each process.
2. Each process should provide information to the operating system for upcoming resource
requests, the number of resources, and how long the resources will be held.
3. It helps the operating system manage and control process requests for each type of resource
in the computer system.
4. The algorithm has a Max resource attribute that represents indicates each process can hold
the maximum number of resources in a system.
Disadvantages:-
1. It requires a fixed number of processes, and no additional processes can be started in the
system while executing the process.
2. The algorithm does no longer allows the processes to exchange its maximum needs while
processing its tasks.
3. Each process has to know and state their maximum resource requirement in advance for the
system.
4. The number of resource requests can be granted in a finite time, but the time limit for
allocating the resources is one year.
When working with a banker's algorithm, it requests to know about three things:-
❖ How much each process can request for each resource in the system. It is denoted by the [MAX]
request.
`
❖ How much each process is currently holding each resource in a system. It is denoted by the
[ALLOCATED] resource.
❖ It represents the number of each resource currently available in the system. It is denoted by the
[AVAILABLE] resource.
Conclusion:-
The banker's algorithm is a resource allocation and deadlock avoidance algorithm that tests for
safety by simulating the allocation for predetermined maximum possible amounts of all resources,
then makes an “s-state” check to test for possible activities, before deciding whether allocation
should be allowed to continue the process.
`
References:-
1. Textbook/manual
2. https://www.techtarget.com