Deadlock and Synchronization
Desert

Banker's Algorithm

The banker's algorithm is a resource allocation algorithm and deadlock avoidance algorithm that tests for safety by simulating the alocation for predetermined maximum possible amounts of all resources and making decision whether allocation should be allowed or not.

Lock_varia

Lock Variable

A lock variable provides the simplest synchronisation mechanism for processes. It is software mechanism implemented in user mode. It is busy waiting solution that keeps CPU busy even when its technically waiting. If lock=0, CS is vacant otherwise it is occupied.

Test_set_lock

Test Set Lock

This mechanism is a hardware solution to the synchronization problem. It ensures Mutual exclusion and progress. Before entering into CS, a process inquires about the shared lock (either 0 or 1). If it is locked, it keeps on waiting else it enters into CS.

Canyons

Turn Variable

Also known as Strict Alteration Approach, is the software mechanism implemented at user mode. It is busy waiting solution which can be implemented for two processes. A turn variable is used which is actually a lock. It is shared varibale between two processes.

Canyons

Peterson Method

It is software based Solution. It has two shared variable for interest and turn. It is solution for mutual exclusion, progress and bounded waiting as only one process allowed in CS and every process gets a fair chance and no process blocks other process from entering CS.

Snowy Mountains

Binary Semaphore

They are also known as mutex locks as it provides mutual exclusion. This type of semaphores have their value restricted to 0 and 1. The wait operation works only if semaphore=1, and the signal operation succeeds when semaphore=0.

Canyons

Counting Semaphore

They can have any value. They can be used to control access to a resource that has a limitation on the number of simultaneous access. The semaphore can be initialised to the number of instances of the resource. If process find remaining_instances > 0 then it decreses the value and enter CS. During exit the value will be increased by 1.

Desert

Producer and Consumer

It is a classical multi-process synchronisation problem. There is one producer and one consumer. Producer is producing some items until buffer is full, whereas consumer consumes the item until buffer is empty. They share same memory buffer which is of fixed size. But both cannot access the memory buffer at the same time.

Desert

Dining Philosopher's problem

There are 5 philosophers sharing a circular table and they eat and think alternatively. There is a bowl of rice for each philosophers and 5 chopsticks. A philosopher needs both their right and left chopstick to eat. A philosopher may eat if there are both chopsticks available else puts down their chopstick and begin thinking again.