vault backup: 2022-10-30 15:25:53

This commit is contained in:
Jet Hughes 2022-10-30 15:25:53 +13:00
parent 3b674050e3
commit e87d0dbde2
2 changed files with 30 additions and 2 deletions

View File

@ -107,7 +107,34 @@ again:
```
## for mutual exclusion
![slide|400](https://i.imgur.com/fkBl7PR.png)
semaphore without busy waiting ![](https://i.imgur.com/bLzY5q3.png)
![mutex|400](https://i.imgur.com/fkBl7PR.png)
![producer consumer again](https://i.imgur.com/ZN8bonW.png)
range of semaphore init vals
- 1 for mutex
- 0 for process sync
- >1 for concurrent processes/threads
- negative values tell us how many processes are waiting
# Deadlock
Definition of deadlock: a set of processes is in a deadlocked state if every process is waiting for an event that can only be caused by another process in the set.
![slide|400](https://i.imgur.com/XTSVwVI.png)
conditions
- mutual exclusion: at least one of the held resources must be nonsharable
- hold and wait: must be at least one process holding a resource and one waiting
- no preemption: a resource can only be released by the process thats holding it
- circular wait:
- P1 is waiting on a resource held by P2;
- P2 is waiting on . . .
- Pn is waiting on a resource held by P1.
typical solution
- break wait by acquiring lock in the same order
- ![](https://i.imgur.com/tDCTXWu.png)
os solution
- ![](https://i.imgur.com/1qHM2w0.png)

View File

@ -50,6 +50,7 @@ tags:
- [17-processes-communication](notes/17-processes-communication.md)
- [18-processes-sharing-and-threads](notes/18-processes-sharing-and-threads.md)
- [19-cpu-scheduling](notes/19-cpu-scheduling.md)
- [20-sync-deadlock](notes/20-sync-deadlock.md)
# Archive