vault backup: 2025-03-08 17:36:57
This commit is contained in:
parent
414e2ab154
commit
647ba29219
1 changed files with 7 additions and 4 deletions
|
@ -43,6 +43,8 @@ Different processes work to let all of them succeed in their task.
|
||||||
- only produced data can be consumed
|
- only produced data can be consumed
|
||||||
- every datum can be consumed at most once
|
- every datum can be consumed at most once
|
||||||
|
|
||||||
|
>[!example] London Trip example
|
||||||
|
>You want to organize a trip to London with your friends and you decide to divide the tasks: one of your friends will buy the tickets, another one will book the hotel, and another one will plan the museum to visit. After all of them completed the assigned task, you can go.
|
||||||
#### Competition
|
#### Competition
|
||||||
Different processes aim at executing some action, but only one of them succeeds.
|
Different processes aim at executing some action, but only one of them succeeds.
|
||||||
Usually, this is related to the access of the same shared resource.
|
Usually, this is related to the access of the same shared resource.
|
||||||
|
@ -62,16 +64,17 @@ While `read()` and `write()` may be considered as atomic, their sequential compo
|
||||||
|
|
||||||
![[Pasted image 20250303090135.png]]
|
![[Pasted image 20250303090135.png]]
|
||||||
|
|
||||||
### Mutual Exclusion (MUTEX)
|
#### Mutual Exclusion (MUTEX)
|
||||||
Ensure that some parts of the code are executed as *atomic*.
|
Ensure that some parts of the code are executed as *atomic*.
|
||||||
This is needed in competition but also in cooperation.
|
>[!warning]
|
||||||
|
>MUTEX is needed **both** in competition and in cooperation [[### Synchronization: cooperation vs competition|synchronization]].
|
||||||
|
|
||||||
Of course, MUTEX is required only when accessing shared data.
|
Of course, MUTEX is required only when accessing shared data.
|
||||||
|
|
||||||
###### Critical section
|
>[!def] Critical Section
|
||||||
A set of code parts that must be run without interferences, i.e. when a process is in a certain shared object (C.S.) than no other process is on that C.S..
|
A set of code parts that must be run without interferences, i.e. when a process is in a certain shared object (C.S.) than no other process is on that C.S..
|
||||||
|
|
||||||
###### MUTEX problem
|
##### MUTEX problem
|
||||||
Design an entry protocol (lock) and an exit protocol (unlock) such that, when used to encapsulate a C.S. (for a given shared object), ensure that at most one process at a time is in a C.S. (for that shared object).
|
Design an entry protocol (lock) and an exit protocol (unlock) such that, when used to encapsulate a C.S. (for a given shared object), ensure that at most one process at a time is in a C.S. (for that shared object).
|
||||||
|
|
||||||
We assume that all C.S.s terminate and that the code is well-formed (*lock ; critical section ; unlock*).
|
We assume that all C.S.s terminate and that the code is well-formed (*lock ; critical section ; unlock*).
|
||||||
|
|
Loading…
Reference in a new issue