@@ -6,23 +6,21 @@ Dining Philosophers
66Overview
77********
88
9- An implementation of a solution to the Dining Philosophers problem (a classic
10- multi-thread synchronization problem). This particular implementation
11- demonstrates the usage of multiple preemptible and cooperative threads of
12- differing priorities, as well as dynamic mutexes and thread sleeping.
13-
14- The philosopher always tries to get the lowest fork first (f1 then f2). When
15- done, he will give back the forks in the reverse order (f2 then f1). If he
16- gets two forks, he is EATING. Otherwise, he is THINKING. Transitional states
17- are shown as well, such as STARVING when the philosopher is hungry but the
18- forks are not available, and HOLDING ONE FORK when a philosopher is waiting
19- for the second fork to be available.
9+ An implementation of a solution to the Dining Philosophers problem (a classic multi-thread
10+ synchronization problem). This particular implementation demonstrates the usage of multiple
11+ preemptible and cooperative threads of differing priorities, as well as dynamic mutexes and thread
12+ sleeping.
13+
14+ The philosopher always tries to get the lowest fork first (f1 then f2). When done, he will give
15+ back the forks in the reverse order (f2 then f1). If he gets two forks, he is EATING. Otherwise,
16+ he is THINKING. Transitional states are shown as well, such as STARVING when the philosopher is
17+ hungry but the forks are not available, and HOLDING ONE FORK when a philosopher is waiting for the
18+ second fork to be available.
2019
2120Each Philosopher will randomly alternate between the EATING and THINKING state.
2221
23- It is possible to run the demo in coop-only or preempt-only mode. To achieve
24- this, set these values for CONFIG_NUM_COOP_PRIORITIES and
25- CONFIG_NUM_PREEMPT_PRIORITIES in prj.conf:
22+ It is possible to run the demo in coop-only or preempt-only mode. To achieve this, set these values
23+ for CONFIG_NUM_COOP_PRIORITIES and CONFIG_NUM_PREEMPT_PRIORITIES in prj.conf:
2624
2725preempt-only:
2826
@@ -34,14 +32,13 @@ coop-only:
3432 CONFIG_NUM_PREEMPT_PRIORITIES 0
3533 CONFIG_NUM_COOP_PRIORITIES 6
3634
37- In these cases, the philosopher threads will run with priorities 0 to 5
38- (preempt-only) and -7 to -2 ( coop-only).
35+ In these cases, the philosopher threads will run with priorities 0 to 5 (preempt-only) and -7 to -2
36+ (coop-only).
3937
4038Building and Running
4139********************
4240
43- This project outputs to the console. It can be built and executed
44- on QEMU as follows:
41+ This project outputs to the console. It can be built and executed on QEMU as follows:
4542
4643.. zephyr-app-commands ::
4744 :zephyr-app: samples/philosophers
@@ -67,9 +64,8 @@ Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
6764Debug Threads
6865*************
6966
70- The philosophers sample by default enables :kconfig:option: `CONFIG_DEBUG_THREAD_INFO `.
71- This allows tools like OpenOCD and J-link to inspect thread data using
72- ``info threads ``.
67+ The philosophers sample by default enables :kconfig:option: `CONFIG_DEBUG_THREAD_INFO `. This allows
68+ tools like OpenOCD and J-link to inspect thread data using ``info threads ``.
7369
7470.. zephyr-app-commands ::
7571 :zephyr-app: samples/philosophers
0 commit comments