Skip to content

Fix/priority preemption - #22

Merged
91tleg merged 5 commits into
mainfrom
fix/priority-preemption
Oct 29, 2026
Merged

91tleg merged 5 commits into
mainfrom
fix/priority-preemption

Conversation

@91tleg

@91tleg 91tleg commented Oct 29, 2026

Copy link
Copy Markdown
Owner

No description provided.

- a process now keeps the CPU until it blocks, waits, yields, or a
  strictly higher priority becomes READY; the per-tick rotation to
  equal and lower priorities is gone
- dispatch: preempt only for a strictly higher priority and put the
  preempted process at the head of its queue; the new
  maxrtos_kernel_dispatch_yield lets an equal priority take over and
  queues the caller at the tail
- partition: add maxrtos_partition_yield beside
  maxrtos_partition_dispatch; maxrtos_kernel_yield uses it
- scheduler: add inline enqueue_front, pop and has_higher; the
  dispatch finds the best priority once instead of twice
- svc: after a call that can ready a process, preempt the caller if a
  higher priority is now READY; the check skips a caller that blocked
- svc: timed_wait( 0 ) is a rescheduling point, same as yield
- restart: a restarted process queues behind its equal-priority peers
- docs: describe the dispatch rules in the headers
- clang-format also reflowed existing lines in partition.c
- unit: add test_priority (preemption, yield, head requeue, wake-up
  checks) and test_support.h with test_run_as; port the buffer,
  mutex, semaphore, dispatch, partition, tick and timing tests off
  the old rotation
- sil: add test_process_priority; the busy workers in the fault,
  spatial and privilege tests now yield so restarted peers run
- qemu: add the priority test and its module_priority.json
- hil: add the priority test; rewrite context_integrity so a waking
  high-priority process interrupts the spinners instead of relying
  on time slicing
- context_integrity.S: align the 8-byte spin loop so it cannot
  straddle a 32-byte flash line; unaligned it ran 20 times slower
- clang-format also reflowed existing lines in the ported tests
- bench_context_switch: remove the TICK_ROTATE sample, since a tick
  within a partition switches nothing now; only partition-switch
  ticks are recorded
- run_bench.py: report YIELD, TICK_SWITCH, QUEUE_HANDOFF and
  MUTEX_HANDOFF
- README: describe the remaining samples
- RESULTS: figures at 480 MHz and 64 MHz, caches on and off
- next_id was set to MAXRTOS_INVALID_PROCESS_ID and then overwritten
  before any read, which cppcheck reports as unreadVariable and fails
  the MISRA job
- declare it in the block that uses it
- checked with cppcheck 2.20.0 and its misra.py, exit 0
- clang-format run on dispatch.c
- add maxrtos_arch_fatal(), a weak function that halts by default
  (MAXRTOS_PORT_HALT); an application defines its own to log and
  reset, or to let a watchdog it configures expire
- call it where the kernel cannot continue: an unattributable
  HardFault, a failure in the fault-recovery path, and an invalid
  syscall gate; the HardFault case used to spin in an empty loop
- the kernel owns no watchdog; the README says to configure one and
  feed it from the application
- qemu: add emu_fatal_hook, where a BKPT reaches the application's
  own hook; add emu_finish() to the harness for code that runs where
  the per-tick poll cannot
- clang-format also reflowed existing lines in fault_handlers.c
@91tleg
91tleg merged commit 8be83d4 into main Oct 29, 2026
7 checks passed
@91tleg
91tleg deleted the fix/priority-preemption branch October 29, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant