Skip to content

Commit dca7bf1

Browse files
Update README.md
1 parent 5b3f3c4 commit dca7bf1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

DiningPhilosophers/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ In their analysis they derive a system of preference levels from the distributio
4747

4848
# Swift implementation
4949

50+
This Swift 3.0 implementation of the Chandy/Misra solution is based on GCD and Semaphore tecnique and it could be built on both macOS and Linux.
5051

52+
The code is based on a ForkPair struct used for holding an array of DispatchSemaphore and a Philosopher struct for associate a couple of forks to each Philosopher.
53+
54+
The ForkPair DispatchSemaphore static array is used for waking the neighbour Philosophers any time a fork pair is put down on the table.
55+
56+
A background DispatchQueue is then used to let any Philosopher run asyncrounosly on the background and a global DispatchSemaphore is simply used in order to keep the main thread on wait forever and let the Philosophers contienue forever in their alternate think and eat cycle.
5157

5258
# See also
5359

0 commit comments

Comments
 (0)