https://github.com/slavamuravey/philosophers
The demonstration how to synchronize the work of threads using mutex, semaphore and buffered channel on the example of the problem of dining philosophers.
https://github.com/slavamuravey/philosophers
Last synced: 2 months ago
JSON representation
The demonstration how to synchronize the work of threads using mutex, semaphore and buffered channel on the example of the problem of dining philosophers.
- Host: GitHub
- URL: https://github.com/slavamuravey/philosophers
- Owner: slavamuravey
- Created: 2020-08-03T04:19:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-03T04:35:37.000Z (almost 5 years ago)
- Last Synced: 2023-03-05T05:43:53.632Z (about 2 years ago)
- Language: Go
- Size: 1.95 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Problem
We have N philosophers. Only M of N philosophers can have dinner at the same time.### Solution
##### Only one philosopher can have dinner at the same time
We can use mutex to allow the work of only one thread at the same time.##### More than one philosopher can have dinner at the same time
To allow more threads we can use semaphore or buffered channel (as alternative implementation of semaphore logic).### Demo
To run the demonstration please do:
```shell script
go run ./cmd
```