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

Supervised and unsupervised learning

Blog banner

Cyber-crime Investigation and Future Directions

Blog banner

Assignment-3

Blog banner

Big Data Architecture

Blog banner

Zomato's Secret Digital Marketing Techniques!

Blog banner

Working with Sniffers for monitoring network communication

Blog banner

OS Assignment 3

Blog banner

Twisted world

Blog banner

A Brief Review on Cyber Forensics and its Analysis Tool

Blog banner

Webmail

Blog banner

It's all about our Brain.- The Brain Metaphor

Blog banner

JUSTICE FOR EVERY “BEZUBAAN ANIMAL”

Blog banner

This too shall pass

Blog banner

Different types of scam frauds

Blog banner

Deadlock

Blog banner

Uniprocessor Scheduling

Blog banner

Building a Simple Doctor Appointment System in Common Lisp

Blog banner

Understanding Univariate, Bivariate, and Multivariate Analysis in Data Science

Blog banner

Modern Operating System

Blog banner

A Review on Data Acquisition in Cyber Forensics

Blog banner

Every body is beautiful

Blog banner

Zero Trust Security Model: Revolutionizing Cybersecurity in the Digital Age

Blog banner

Efficiency of SQL Injection Method in Preventing E-Mail Hacking

Blog banner

Memory input output management

Blog banner

How to Avoid being a Victim of Cybercrime

Blog banner

Iphone or Android which is the best smartphone?

Blog banner

Social media

Blog banner

Studying Denial of service attack using DOSHTTP tool

Blog banner

Smartsheet

Blog banner

Multicore CPUs

Blog banner

Device driver

Blog banner

Is Your Password Complex Enough?

Blog banner

DMZ: Your Secret Weapon for Data Security

Blog banner

12 Principles of Animation

Blog banner

Cyber Security Standards

Blog banner

Data Mapping

Blog banner

10 Alien Encounters and Abduction Stories

Blog banner

Simple AI Symptom Diagnosis Using LISP – Rule-Based Expert System

Blog banner

EFT

Blog banner

Cryptanalysis tool

Blog banner

Quality check in IT services

Blog banner

TRAIN TRAVELING

Blog banner