doc: samples: philosophers: fix formatting and spelling

Improved the formatting of the overview and fixed minor
grammar issues

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé 2024-05-16 15:20:14 +02:00 committed by Carles Cufí
commit adfa3346c2

View file

@ -12,25 +12,28 @@ preemptible and cooperative threads of differing priorities, as well as dynamic
sleeping. sleeping.
The philosopher always tries to get the lowest fork first (f1 then f2). When done, he will give The philosopher always tries to get the lowest fork first (f1 then f2). When done, he will give
back the forks in the reverse order (f2 then f1). If he gets two forks, he is EATING. Otherwise, back the forks in the reverse order (f2 then f1). If he gets two forks, he is ``EATING``.
he is THINKING. Transitional states are shown as well, such as STARVING when the philosopher is Otherwise, he is ``THINKING``. Transitional states are shown as well, such as ``STARVING`` when the
hungry but the forks are not available, and HOLDING ONE FORK when a philosopher is waiting for the philosopher is hungry but the forks are not available, and ``HOLDING ONE FORK`` when a philosopher
second fork to be available. is waiting for the second fork to be available.
Each Philosopher will randomly alternate between the EATING and THINKING state. Each Philosopher will randomly alternate between the ``EATING`` and ``THINKING`` states.
It is possible to run the demo in coop-only or preempt-only mode. To achieve this, set these values It is possible to run the demo in `coop-only` or `preempt-only` mode. To achieve this, set these
for CONFIG_NUM_COOP_PRIORITIES and CONFIG_NUM_PREEMPT_PRIORITIES in prj.conf: values for ``CONFIG_NUM_COOP_PRIORITIES`` and ``CONFIG_NUM_PREEMPT_PRIORITIES`` in :file:`prj.conf`:
preempt-only: preempt-only
.. code-block:: cfg
CONFIG_NUM_PREEMPT_PRIORITIES 6 CONFIG_NUM_PREEMPT_PRIORITIES=6
CONFIG_NUM_COOP_PRIORITIES 0 CONFIG_NUM_COOP_PRIORITIES=0
coop-only:
CONFIG_NUM_PREEMPT_PRIORITIES 0 coop-only
CONFIG_NUM_COOP_PRIORITIES 6 .. code-block:: cfg
CONFIG_NUM_PREEMPT_PRIORITIES=0
CONFIG_NUM_COOP_PRIORITIES=6
In these cases, the philosopher threads will run with priorities 0 to 5 (preempt-only) and -7 to -2 In these cases, the philosopher threads will run with priorities 0 to 5 (preempt-only) and -7 to -2
(coop-only). (coop-only).
@ -50,7 +53,7 @@ This project outputs to the console. It can be built and executed on QEMU as fo
Sample Output Sample Output
============= =============
.. code-block:: console .. code-block::
Philosopher 0 [P: 3] HOLDING ONE FORK Philosopher 0 [P: 3] HOLDING ONE FORK
Philosopher 1 [P: 2] HOLDING ONE FORK Philosopher 1 [P: 2] HOLDING ONE FORK
@ -78,7 +81,7 @@ tools like OpenOCD and J-link to inspect thread data using ``info threads``.
OpenOCD Sample Output OpenOCD Sample Output
===================== =====================
.. code-block:: console .. code-block::
Thread 1 received signal SIGINT, Interrupt. Thread 1 received signal SIGINT, Interrupt.
[Switching to Thread 537003160] [Switching to Thread 537003160]
@ -100,7 +103,7 @@ OpenOCD Sample Output
Info : Getting thread 537002104 reg list Info : Getting thread 537002104 reg list
7 Thread 537002104 (Name: Philosopher 0, prio:3,useropts:4) 0x08001404 in arch_irq_unlock (key=0) at zephyr/mainline/zephyr/include/arch/arm/asm_inline_gcc.h:95 7 Thread 537002104 (Name: Philosopher 0, prio:3,useropts:4) 0x08001404 in arch_irq_unlock (key=0) at zephyr/mainline/zephyr/include/arch/arm/asm_inline_gcc.h:95
.. code-block:: console .. code-block::
Philosopher 0 [P: 3] STARVING Philosopher 0 [P: 3] STARVING
Philosopher 1 [P: 2] HOLDING ONE FORK Philosopher 1 [P: 2] HOLDING ONE FORK
@ -113,7 +116,7 @@ OpenOCD Sample Output
J-Link Sample Output J-Link Sample Output
==================== ====================
.. code-block:: console .. code-block::
Thread 2 received signal SIGTRAP, Trace/breakpoint trap. Thread 2 received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 537920592] [Switching to Thread 537920592]
@ -129,7 +132,7 @@ J-Link Sample Output
7 Thread 537920240 (Philosopher 4 PENDING PRIO 255) arch_swap (key=0) at zephyr/mainline/zephyr/arch/arm/core/swap.c:53 7 Thread 537920240 (Philosopher 4 PENDING PRIO 255) arch_swap (key=0) at zephyr/mainline/zephyr/arch/arm/core/swap.c:53
8 Thread 537920416 (Philosopher 5 SUSPENDED PRIO 254) arch_swap (key=key@entry=0) at zephyr/mainline/zephyr/arch/arm/core/swap.c:53 8 Thread 537920416 (Philosopher 5 SUSPENDED PRIO 254) arch_swap (key=key@entry=0) at zephyr/mainline/zephyr/arch/arm/core/swap.c:53
.. code-block:: console .. code-block::
Philosopher 0 [P: 3] STARVING Philosopher 0 [P: 3] STARVING
Philosopher 1 [P: 2] EATING [ 475 ms ] Philosopher 1 [P: 2] EATING [ 475 ms ]