zephyr/samples/philosophers/sample.yaml
Andy Ross 851d14afc8 kernel/sched: Remove "cooperative scheduling only" special cases
The scheduler has historically had an API where an application can
inform the kernel that it will never create a thread that can be
preempted, and the kernel and architecture layer would use that as an
optimization hint to eliminate some code paths.

Those optimizations have dwindled to almost nothing at this point, and
they're now objectively a smaller impact than the special casing that
was required to handle the idle thread (which, obviously, must always
be preemptible).

Fix this by eliminating the idea of "cooperative only" and ensuring
that there will always be at least one preemptible priority with value
>=0.  CONFIG_NUM_PREEMPT_PRIORITIES now specifies the number of
user-accessible priorities other than the idle thread.

The only remaining workaround is that some older architectures (and
also SPARC) use the CONFIG_PREEMPT_ENABLED=n state as a hint to skip
thread switching on interrupt exit.  So detect exactly those platforms
and implement a minimal workaround in the idle loop (basically "just
call swap()") instead, with a big explanation.

Note that this also fixes a bug in one of the philosophers samples,
where it would ask for 6 cooperative priorities but then use values -7
through -2.  It was assuming the kernel would magically create a
cooperative priority for its idle thread, which wasn't correct even
before.

Fixes #34584

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-05-24 23:38:16 -04:00

42 lines
1.1 KiB
YAML

sample:
name: Dining Philosophers
common:
extra_args: DEBUG_PRINTF=1
tags: introduction
harness: console
integration_platforms:
- native_posix
harness_config:
type: multi_line
ordered: false
regex:
- ".*STARVING.*"
- ".*DROPPED ONE FORK.*"
- ".*THINKING.*"
- ".*EATING.*"
tests:
sample.kernel.philosopher:
tags: introduction
sample.kernel.philosopher.same_prio:
extra_args: "-DSAME_PRIO=1"
sample.kernel.philosopher.static:
extra_args: "-DSTATIC_OBJS=1"
sample.kernel.philosopher.semaphores:
extra_args: "-DFORKS=SEMAPHORES"
sample.kernel.philosopher.stacks:
extra_args: "-DFORKS=STACKS"
sample.kernel.philosopher.fifos:
extra_args: "-DFORKS=FIFOS"
sample.kernel.philosopher.lifos:
extra_args: "-DFORKS=LIFOS"
sample.kernel.philosopher.preempt_only:
extra_configs:
- CONFIG_NUM_PREEMPT_PRIORITIES=6
- CONFIG_NUM_COOP_PRIORITIES=0
- CONFIG_BT=n
- CONFIG_NETWORKING=n
sample.kernel.philosopher.coop_only:
extra_configs:
- CONFIG_NUM_PREEMPT_PRIORITIES=0
- CONFIG_NUM_COOP_PRIORITIES=7