wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

Deadlock and Starvation

profile
Abutalha Solanki
Aug 15, 2024
0 Likes
0 Discussions
82 Reads

Deadlock


Deadlock is a critical issue in concurrent systems where two or more processes are stuck in a state of perpetual waiting, unable to proceed with their execution because each process is holding a resource and waiting for another resource that is held by another process. This situation leads to a standstill where none of the processes can continue, effectively bringing parts of the system to a halt.


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


1.Mutual Exclusion: At least one resource must be held in a non-sharable mode; that is, only one process can use the resource at any given time. If another process requests that resource, it must be blocked until the resource is released.


2. Hold and Wait: A process is currently 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 removed from the processes holding them; they must be released voluntarily by the process after it has completed its task.


4.Circular Wait: A set of processes are waiting for resources in such a way that each process in the set is waiting for a resource that is held by the next process in the set, forming a circular chain.


To manage deadlocks, several strategies can be employed:


- Deadlock Prevention: This involves designing the system in such a way that at least one of the four conditions necessary for deadlock cannot occur. For instance, by ensuring that resources are allocated in such a way that circular wait cannot occur, deadlocks can be prevented. However, this approach can be restrictive and may lead to inefficiency.


- Deadlock Avoidance: This strategy requires that the system has some additional information about how resources are requested. The system makes decisions dynamically to ensure that deadlock is avoided. The Banker's algorithm is a well-known example of a deadlock avoidance strategy, which tests whether allocating resources will keep the system in a safe state.


- Deadlock Detection and Recovery: In this approach, the system does not prevent or avoid deadlocks but instead allows them to occur, then detects them and takes action to recover. This can involve terminating one or more processes to break the deadlock or preempting resources from some processes.


Starvation


Starvation, also known as indefinite blocking, occurs when a process is perpetually denied access to the resources it needs to proceed with its execution, despite the system being in a state where these resources are technically available. Unlike deadlock, where processes are mutually blocked, starvation typically affects lower-priority processes that are continually overlooked in favor of higher-priority ones.


Starvation can happen in various scenarios, most commonly in systems where resources are allocated based on priority. For example, in a priority-based scheduling algorithm, higher-priority processes are allowed to execute before lower-priority ones. If new high-priority processes keep arriving, the low-priority process may never get a chance to run, leading to starvation.


Preventing starvation typically involves implementing strategies that ensure fairness in resource allocation. One common technique is **aging**, where the priority of a process increases the longer it waits in the queue. Over time, even a low-priority process will accumulate enough priority to eventually gain access to the resources it needs.


Both deadlock and starvation are significant concerns in the design of operating systems and concurrent systems. While deadlock can bring a system to a complete halt, starvation can degrade system performance by allowing some processes to monopolize resources indefinitely. Effective management of these issues is crucial for maintaining the reliability and efficiency of a system.


Comments ()


Sign in

Read Next

Ganpati Special: Exotic 51 Modak flavours by Mahavir Dryfruits

Blog banner

(Input/Output) in os

Blog banner

Building a Better You: Fitness Tips and Inspiration.

Blog banner

What makes Nugget RC Racing Florida’s Most Exciting Racing Events?

Blog banner

Things You Should Leave Behind In 2025, Whilst In 2026

Blog banner

Facebook marketing

Blog banner

Deadlocks

Blog banner

A-B-C of Networking: Part-3 (Topology [Ring, Tree, Mesh])

Blog banner

MACHINE LEARNING

Blog banner

Fault Tolerance

Blog banner

USES OF WHATSAPP

Blog banner

BIRYANI ! The history you never knew about

Blog banner

ART AND CULTURE OF VRINDAVAN

Blog banner

Virtual machine

Blog banner

Data Warehouse Bus Matrix

Blog banner

DIGITAL ECONOMY

Blog banner

Vulnerability Assessment (Vulnerability Analysis)

Blog banner

How To Invest in Indian Stock Market For Beginners. ~ Tutorial 2 (NSDL And CSDL) Continued...

Blog banner

10 Types of Friends in every friend group

Blog banner

Principles of Service Operation

Blog banner

Diwali

Blog banner

Starvation and Deadlock.

Blog banner

Winter-to-Spring Smile Care: How Sydney’s Late-August Winds Impact Your Teeth & Gums

Blog banner

Modern operating system

Blog banner

MQTT (MQ Telemetry Transport) in Data Science

Blog banner

Wiretapping

Blog banner

The Power of Pretend Play: What Role-Playing Teaches Preschoolers

Blog banner

MEMORY MANAGEMENT REQUIREMENT

Blog banner

"Audit" In Data Science

Blog banner

?Why Social and Emotional Skills Matter More Than ABCs in Early Years?

Blog banner

Network Security Risks

Blog banner

Ethical Hacking

Blog banner

Concurrency and memory

Blog banner

Use It or Lose It: Why November Is the Best Time to Claim Your Dental Extras and Medicare CDBS Before Year-End

Blog banner

SMARTSHEET MANAGEMENT SYSTEM

Blog banner

Traditional UNIX Scheduling

Blog banner

Personalized Movie Recommendations with Data Science

Blog banner

Firewall

Blog banner

Online Games

Blog banner

Getting to Kashmir: Alternative to the Jammu-Srinagar highway

Blog banner

SPEM

Blog banner

Linux VServer Architecture

Blog banner