wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

Deadlock

profile
Darshan Somaiya
Aug 16, 2024
1 Like
0 Discussions
157 Reads

DEADLOCK


Deadlock is a situation in an operating system where a set of processes become stuck because each process in the set is waiting for another process to release resources. This leads to a cascade of dependencies where nothing can really progress, thus halting everything.


Four Conditions for Deadlock 

A deadlock can only occur when the following four conditions are met simultaneously:


1. Mutual Exclusion: At least one resource must be held in a non-sharable mode, and only one process can use the resource at a time.


2. Hold and Wait: A process holding at least one resource is waiting to acquire additional resources that are currently held by other processes.


3. No Preemption: Resources cannot be preempted from the process holding them; they can only be released voluntarily by the process.


4. Circular Wait: There is a set of processes such that each process in the chain is waiting for another which is ahead, forming a circle.


Example Scenario:

Suppose there are two processes and two resources. P1 process requests R1, and P2 requests R1 & holds R2. Neither process will release the resources it currently holds, and neither can proceed until it is able to acquire a resource that both processes are waiting on for completion. Therefore, both stall simultaneously, giving rise to deadlock.


Deadlock Prevention and Avoidance 

Operating systems employ various strategies to prevent or avoid deadlock:


- Deadlock Prevention: This is a set of methods for ensuring that at least one of the necessary conditions cannot hold. It can be done by requiring all processes to ask for resources at once or by preventing circular wait, etc.


- Deadlock Avoidance: It employs algorithms like the Banker’s Algorithm, which dynamically check the state of resource allocation to make sure a system will never enter an unsafe state where deadlock can happen.


Some systems may allow deadlocks to occur but have standby algorithms in place for detection and recovery, such as terminating one or more processes involved to free up resources.


Comments ()


Sign in

Read Next

Process and Threading

Blog banner

Why Soft Skills Matter as Much as Grades?

Blog banner

Top 5 Tech Innovations of 2018

Blog banner

Firewall

Blog banner

Virtual Memory

Blog banner

Deadlock

Blog banner

Rock, Paper, Scissors Game in Common Lisp

Blog banner

How To Implement Search Engine Marketing (Sem) Strategy Effectively

Blog banner

Digital Marketing

Blog banner

Concurrency:Deadlock and Starvation

Blog banner

The Role of Summer Camps in Early Childhood Development

Blog banner

How To Setup DVWA Using XAMPP on Windows

Blog banner

Latest Email Marketing Techniques

Blog banner

A Day in the Life at Elzee: What Your Child Does Between Drop-Off and Pick-Up

Blog banner

Blockchain technology: security risk and prevention

Blog banner

Virtual Machine

Blog banner

Types of Malware in Cyber Security

Blog banner

"Audit" In Data Science

Blog banner

The New Classic: Indo Western Patola Outfits for Today’s Woman

Blog banner

RSA (Rivest-Shamir-Adelman) Algorithm

Blog banner

OS Assignment 1

Blog banner

Short-Form Video Marketing: Why It's Dominating the Internet

Blog banner

LinkedIn: Watch out for these 7 upcoming updates in 2023

Blog banner

What is Segmentation?

Blog banner

Understanding - Proof of Work!

Blog banner

I Personally

Blog banner

VIRTUAL MACHINE

Blog banner

Deadlock and Starvation in an Operating System

Blog banner

WORKFRONT SOFTWARE

Blog banner

OPERATING SYSTEM

Blog banner

Data Visualization- Importance and tools (Tableau,Power BI, Matplotlib)

Blog banner

Why we fail after giving 100% ?

Blog banner

A True Friendship

Blog banner

The Joy of Giving: How Festivals Teach Children Empathy and Gratitude

Blog banner

IOT Hacking Techniques

Blog banner

Top 5 Benefits of Artificial Intelligence

Blog banner

Europe Through My Lens

Blog banner

Introduction to Solidity Programming for Blockchain Development

Blog banner

OLA

Blog banner

"Games and the future"

Blog banner

Deadlock and starvation in operating system

Blog banner

The Power of Cyber Forensic in Solving Crimes

Blog banner