Skip to content

k_thread_foreach api breaks real time semantics #13318

@mubes

Description

@mubes

Describe the bug
When 'kernel stacks' or 'kernel threads' commands are entered at the command prompt realtime performance is lost.

To Reproduce

  1. Enable shell, kernel extensions and thread/stack info. Specifically, the following must be defined;
    CONFIG_INIT_STACKS, CONFIG_THREAD_MONITOR, CONFIG_THREAD_STACK_INFO
  2. Setup short period secondary task which is dependent on external interrupt (e.g. to toggle a pin in response to incoming pin change)
  3. Compile (tested on STM32F429 build)
  4. At the command prompt type 'kernel stacks' or 'kernel threads'
  5. Observe that realtime response of other task is lost.

I think this is due to the k_spin_lock in kernel/thread.c::k_thread_foreach ... would it not be sufficient to just do a k_sched_lock here? Worst consequence would be incorrectly reported threads/stacks for the case that the printing task manipulated one of the, which it's not supposed to do anyway.

Expected behavior
Interrupt responding second task should continue to operate correctly.

Impact
What impact does this issue have on your progress (e.g., annoyance, showstopper)
Annoyance. Prevents use of kernel threads/kernel stacks commands on a realtime system.

Screenshots or console output
N/A

Environment (please complete the following information):
Linux, Zephyr SDC, 1.3.99, a4e950a

Metadata

Metadata

Assignees

Labels

EnhancementChanges/Updates/Additions to existing featuresarea: Kernel

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions