Skip to content

Reschedule points are currently undocumented #21111

@andyross

Description

@andyross

Zephyr has never been good about documenting its schedule points, where a call to z_swap() (via the z_reschedule family of internal utilities) can be made and a new thread can be selected to run. This complicates user analysis, especially in the case of cooperative/non-preemptible threads, and can lead to surprising behavior (see for example #20802, where a priority change due to mutex release is not immediately honored by the scheduler).

We should be rigorous about this and document all the circumstances under which each API can reschedule. For example:

  • k_sem_take() will swap only on an empty semaphore
  • k_sem_give() will always reschedule, even if no other threads were waiting
  • k_mutex_unlock() will not swap, even if the priority changes (reschedule not done after mutex unlock #20802)
  • k_pipe_put() will not swap, except if an async message is queued

And lots more...

The lack of documentation here is blocking work on existing code, so we really need to get this fixed.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions