wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

Deadlock in Operating System

profile
Diya Singh
Aug 13, 2024
0 Likes
0 Discussions
112 Reads

What is Deadlock?

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. 

Disadvantages of Deadlock:

Deadlock is an infinite process it means that once a process goes into deadlock it will never come out of the loop and the process will enter for an indefinite amount of time. There are only detection, resolution, and prevention techniques. But, there are no Deadlock-stopping techniques.

How Deadlock can occur?

Lets consider following situation:

  • Process1 obtains Resource1
  • Process2 obtains Resource2

Process 1 requires Resource 2 to continue execution but is unable to do so because Process 2 is currently holding Resource 2. Similarly, Process 2 requires Resource 1 to continue execution but is unable to do so because Process 1 is currently holding Resource 1. Both processes are now stuck in a loop:

  • Process 1 is awaiting Resource 2 from Process 2.
  • Process 2 is awaiting Resource 1 from Process 1.

We have a deadlock because neither process can release the resource it is holding until it completes its task, and neither can proceed without the resource the other process is holding. Both processes are effectively “deadlocked,” unable to move forward. To break the deadlock and free up resources for other processes in this situation, an external intervention, such as the operating system killing one or both processes, would be required.

Necessary conditions for the occurrence of deadlock:

1) Mutual Exclusion:

Mutual Exclusion condition requires that at least one resource be held in a non-shareable mode, which means that only one process can use the resource at any given time. 

As an example:

  • Process 1 obtains Resource 1
  • Process 2 acquires Resource 2

2) Hold and Wait:

The hold and wait condition specifies that a process must be holding at least one resource while waiting for other processes to release resources that are currently held by other processes. In our example,

  • Process 1 has Resource 1 and is awaiting Resource 2.
  • Process 2 currently has Resource 2 and is awaiting Resource 1.
  • Both processes hold one resource while waiting for the other, satisfying the hold and wait condition.

3) No Preemption:

Preemption is the act of taking a resource from a process before it has finished its task. According to the no preemption condition, resources cannot be taken forcibly from a process a process can only release resources voluntarily after completing its task. 

For example – Process1 have resource1 and requesting for resource2 that is hold by process2. then process1 preempt resource1 and after some time it try to restart by requesting both resource1 and resource2.

4) Circular Wait:

This condition implies that circular processes must exist, with each process waiting for a resource held by the next process in the chain. In our scenario, Process 1 is waiting for Resource 2, which is being held by Process 2. Process 2 is awaiting Resource 1 from Process 1. This circular chain of dependencies causes a deadlock because neither process can proceed, resulting in a system shutdown.

Conclusion:

Deadlocks are major problems in computers in which two or more processes remain blocked forever, each waiting for the other to release resources. A deadlock requires four conditions: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlocks consume resources and reduce system performance, hence their avoidance, detection, and resolution are critical in operating systems.


Comments ()


Sign in

Read Next

How to Plan a Week of Healthy Meals Without Stress

Blog banner

Decoding the Weave — How to Identify Original Patola Art on a Fabric

Blog banner

The seven-step improvement process

Blog banner

Virtual Machine

Blog banner

What is Spyware? and examples of them.

Blog banner

Financial Fraud Detection

Blog banner

The Future of Cybersecurity: Trends, Challenges, and Strategies

Blog banner

Time Series Analysis

Blog banner

Electronic Evidence in Cyber Forensics

Blog banner

Understanding the 4 Types of Learning Methods in Early Childhood

Blog banner

BrainGate Technology

Blog banner

Image Steganography: Hiding Secrets in Plain Sight

Blog banner

The 60-Minute Window: What to Do (And What NOT to Do) When You Knock Out a Tooth

Blog banner

Modern Operating System

Blog banner

OPERATING SYSTEM OBJECTIVES AND FUNCTIONS

Blog banner

Beyond the Track: Why the Best Hotel in Arcadia, Florida, Completes Your IMSA Sebring Getaway

Blog banner

Dos (Denial of service) Attack

Blog banner

Sweet and Sour Mango Pickle (Gol Keri)

Blog banner

Outlook mail

Blog banner

Short note on expert system

Blog banner

**THE MUJAWARR: Transforming the Logistics Industry**

Blog banner

Top 3 Places To Stay In Vienna

Blog banner

Concurrency management in operating systems

Blog banner

I Personally

Blog banner

Business-to-Business

Blog banner

MQTT (MQ Telemetry Transport) in Data Science

Blog banner

Brain wash of social media

Blog banner

All you need to know about “On-page SEO”

Blog banner

Principles of Concurrency

Blog banner

Deadlock and starvation

Blog banner

How Does SSO Works

Blog banner

Proton mail

Blog banner

Gis in agriculture and farming

Blog banner

Self defence

Blog banner

Importance of self defence for girls

Blog banner

Raising Emotionally Intelligent Students: The Classroom Beyond Academics

Blog banner

The House ??of Patola Designs: Traditional Weaves with a Modern Twist

Blog banner

Web Site

Blog banner

How to grow followers on Instagram business account?

Blog banner

26/11 The Black Day Of Mumbai

Blog banner

Sensory Play for Toddlers: Boosting Curiosity Through Touch, Sound, and Colour

Blog banner

The Difference Between Plaque and Tartar Explained Simply

Blog banner