Add README
This commit is contained in:
38
src/README.MD
Normal file
38
src/README.MD
Normal file
@@ -0,0 +1,38 @@
|
||||
# Dining Philosophers
|
||||
|
||||
N philosophers are seated around a round table and do what philosophers usually do, ~thinking~. However after some extensive thinking
|
||||
philosophers grow hungry. Luckily they are already seated at a table each in front of a plate of spaghetti.
|
||||
In order to eat they have to pick up both forks that lie next to them and which they share with their right and left neighbor respectively.
|
||||
If one of the forks is currently taken they patiently wait for their fellow philosopher to finish before picking up the fork.
|
||||
Usually the dining philosophers would keep thinking and eating indefinitely however for the sake of sanity of all involved they have agreed
|
||||
to limit themselves to 10 thinking sessions.
|
||||
|
||||
Your Task: Adjust implementation of Philosopher and Fork in DiningPhilosophers.kt to fill these requirements when run in different
|
||||
coroutines:
|
||||
|
||||
* Each philosopher starts THINKING until they get HUNGRY, pick up two forks and start EATING and repeat this process 10 times.
|
||||
* In particular the N philosophers finish their thinking and do not keep waiting for each other indefinitely (Deadlock).
|
||||
* Before EATING a philosopher always picks up his left and right fork
|
||||
* When a fork is currently picked up, no other philosopher tries to pick it up
|
||||
* (Bonus): Since all philosophers agree to limit their thinking, they are all ensured to eventually be able to eat.
|
||||
But what if the philosophers would think forever like they usually do. Does your solution ensure that every philosopher is allowed to eat
|
||||
eventually and is not denied the forks forever. (Starvation)
|
||||
|
||||
You can solve this problem with only Mutex's and Semaphores, however you are free and welcome to use any Kotlin coroutine feature you
|
||||
learned this morning. The tests in DiningPhilosophersTest.kt can help you determine if your solution fulfills the requirements.
|
||||
The existing code only serves at a starting point you are free to change it (may have to change tests as well)
|
||||
|
||||
# Consumer Producer Problem
|
||||
|
||||
Following the thematic of the first S-Team workshop we want to orchestrate another Weißwurst Frühstück.
|
||||
This time we have multiple producers who produce Weißwürste and deliver them to the kitchen where they can be picked up by
|
||||
consumers and be ~consumed~. Following requirements:
|
||||
|
||||
* The kitchen has a limited capacity, producers do not deliver to the kitchen if it is full
|
||||
* Each consumer has an individual fixed hunger for Weißwürste, each consumed Weißwurst reduces hunger by one
|
||||
* Producers produce Weißwürste until all consumers are satisfied.
|
||||
* Consumers do not eat more than they have hunger
|
||||
* No Weißwürste are left over
|
||||
* (Bonus): Producers produce a spoiled Weißwurst with some small probability, but only consumers have the possibility to detect
|
||||
spoiled Weißwurst, spoiled Weißwurst are discarded by consumers and do not reduce their hunger
|
||||
|
||||
Reference in New Issue
Block a user