wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

Deadlocks in operating system

profile
NAHIDA SHAIKH
Aug 15, 2024
0 Likes
0 Discussions
95 Reads

Deadlock in an operating system occurs when a set of processes become stuck in a situation where none of them can proceed because each process is waiting for a resource that another process holds. This creates a cycle of dependencies that prevents any of the involved processes from continuing.


### Necessary Conditions for Deadlock

For a deadlock to occur, four conditions must be present simultaneously:


1. **Mutual Exclusion**: At least one resource must be held in a non-shareable mode, meaning only one process can use the resource at any given time.


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


3. **No Preemption**: Resources cannot be forcibly taken from a process. They can only be released voluntarily by the process holding them.


4. **Circular Wait**: There exists a set of processes \(\{P_1, P_2, \dots, P_n\}\) such that \(P_1\) is waiting for a resource held by \(P_2\), \(P_2\) is waiting for a resource held by \(P_3\), and so on, with \(P_n\) waiting for a resource held by \(P_1\).


### Deadlock Handling Methods

There are several strategies for handling deadlocks:


1. **Deadlock Prevention**: Modify the system design to ensure that at least one of the necessary conditions for deadlock cannot hold. This could involve:


  - **Eliminating Mutual Exclusion**: Make resources sharable, if possible.

  - **Eliminating Hold and Wait**: Require processes to request all required resources at once.

  - **Eliminating No Preemption**: Allow the system to forcibly take resources from a process.

  - **Eliminating Circular Wait**: Impose an order on resource acquisition.


2. **Deadlock Avoidance**: Dynamically examine the resource allocation state to ensure that a circular wait condition never occurs. The **Banker’s algorithm** is a classic example of a deadlock avoidance algorithm.


3. **Deadlock Detection and Recovery**: Allow deadlocks to occur but have the system detect them and take action to recover. Recovery can involve:


  - **Terminating Processes**: Killing one or more processes to break the deadlock.

  - **Resource Preemption**: Temporarily taking resources away from some processes and reallocating them.


4. **Ignoring Deadlock**: In some systems, deadlock is considered a rare event, so it's ignored. This approach is used by some operating systems like UNIX, where the system does nothing to prevent or avoid deadlock, relying instead on rebooting the system if a deadlock occurs.


Understanding deadlocks and how to handle them is crucial in the design and operation of reliable and efficient operating systems.


Comments ()


Sign in

Read Next

Hubspot

Blog banner

What is online marketing and why do you need to know about it ?

Blog banner

Operating Systems

Blog banner

The Essential Guide to Dynamic Arrays vs. Linked Lists: Which to Use and When ?

Blog banner

memory management

Blog banner

The Procedural Framework for Corporate High-Tech Investigations

Blog banner

Financial Stress and Mental Health

Blog banner

Explain Multiprocessors

Blog banner

Virtual machine and virtualizing

Blog banner

Why Meal Maharaj Prioritises Seasonal Vegetables in Every Meal Box

Blog banner

E-BUSINESS RISK MANAGEMENT

Blog banner

World’s rarest passport owned by 500 people.

Blog banner

Rock, Paper, Scissors Game in Common Lisp

Blog banner

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

Blog banner

Buffer overflow

Blog banner

AOL Mail

Blog banner

Next time you click on "Remind me later", think twice!

Blog banner

Service design process in ITSM

Blog banner

The Power of Forensic Watermarking in the Fight Against Content Piracy

Blog banner

IoT Evolution

Blog banner

Deadlock and Starvation

Blog banner

COMPUTER FORENSICS AND GRAPHICS

Blog banner

OPERATING SYSTEM

Blog banner

Lemon and Chilli Pickle (Limbu Mirchi Achar)

Blog banner

Top 10 Logos and their meanings

Blog banner

"Audit" In Data Science

Blog banner

LINUX VSERVER VIRTUAL MACHINE ARCHITECTURE

Blog banner

Jira Software

Blog banner

IoT Architecture Based Security

Blog banner

Traveling

Blog banner

INDIAN CHEAPEST COSMETICS BRAND

Blog banner

Guidelines for a low sodium diet.

Blog banner

Cyber Forensics in a Ransomware Attack Recovery

Blog banner

5 Things I As A Dentist Would Never Do (And What You Can Learn From It)

Blog banner

Threads

Blog banner

Operating system and overviews

Blog banner

15 Interesting Facts about India

Blog banner

A Statistical Analysis of Player Performance and their Value in cricket

Blog banner

What's Better : Supervised or Unsupervised Learning

Blog banner

Social Media Sentiment Analysis

Blog banner

Data Visualization – Importance and tools (Tableau, Power BI)

Blog banner

STARVATION

Blog banner