Skip to content
TimL03 edited this page Aug 26, 2023 · 5 revisions

Deadlocks:

Many system processes require resources to fulfil tasks like for example accessing file storage, input/output devices and other resources to execute. With many processes trying to access resources at once the probability is high that a resource a process is trying to reserve is currently occupied. If there is for example a Process A, currently occupying a Printer, trying to access a Plotter as well and a Process B, currently occupying a Plotter, trying to access the printer a deadlock will occur because both resources will wait indefinitely for the other to release the resource.

There are a few requirements that have to be met for a deadlock to occur. The requirements are:

1. Mutual Exclusion:

At least one resource must be held in a non-sharable mode, meaning it cannot be simultaneously used by more than one process. The simulation fulfils this because there is a limited number of resources of each type.

2. Hold and Wait:

Processes currently holding resources may request additional resources, while still retaining the resources they already possess. The simulation fulfils this by waiting for the next resource to be found before releasing the last resource it occupies.

3. No Preemption:

Resources cannot be forcibly taken away from a process that is holding them, they can only be released voluntarily by the holding process. The simulation fulfils this because there is no way to take the resources from a process (not by the main thread and not by other processes) once it occupies them.

4. Circular Wait:

A circular chain of two or more processes exists, where each process holds a resource that the next process in the chain is waiting for. The simulation fulfils this because the order in which the resources are being requested is random.

Avoiding/ Preventing Deadlocks

As you could guess: Deadlock prevention is a big and important topic, which is why there are many different approaches to avoid, prevent or reverse deadlock situations.

The program has 4 built-in algorithms to visually show you how they work against Deadlocks:

-Eliminate Hold And Wait ⌛

-Eliminate Circular Wait 🔃

-Eliminate No Preemption 🚦

-Bankier Algorithm 💸

Clone this wiki locally