What is a mutual exclusion?
No two processes are at the critical section at the same time. ()
What is a deadlock
Deadlock is a situation where two or more concurrent processes/threads mutually wait for each other to make progress, so that none of them get any further.
what is starvation?
Starvation, in general, means a situation where some process has been denied service for a long time or has been repeatedly denied service. This can happen due to deadlock or scheduling policy
How the mutual exclusion problem can be solved?
By an object that guarantees mutually exclusive access by processes to a shared resource - the mutex.
What problems do we expect the mutex to solve?
What is a brute force solution?
exhaustive search method in which you try all the possibilities to reach the solution of a problem.
Why not instead of mutex we disable interrupts?
Why not use a simple lock?

Why not use strict alternation?

Why not use flag array?

Why not use Peterson’s algorithm?

mutual exclusion: fixed.
turn can have one of two possible values: 0 or 1. thus the two process cannot simultaneously enter the CS.
deadlock - Fixed.
explained in starvation.
starvation - fixed.
b[i] = true means intention. turn = i, means it is i’s turn to enter the CS. Assume i’m process 1 and i want to enter the CS: if process 0 have no intention, b[1]=false and i’m in. If he does have intention, we’re racing. if the value of turn is 0 on my while loop i get in. else, process 1 gets in. once finished, he sets b[1] = false. means he has no intention to enter. then i can enter. moreover, if process 1 wants immediately to enter again he would set turn = 1, thus he’s stuck in the while loop till i enter.
What is the idea behind Peterson’s 2 algorithm?

Bakery Algorithm:

both processes are in the CS.
How the mutual exclusion problem is solved in the Bakery Algorithm?


What is the test and set instruction?
Decide.
How is test and set can help us solve the starvation problem?
