Skip to content

Conversation

@lyakh
Copy link
Collaborator

@lyakh lyakh commented Jan 6, 2026

sys_sem semaphores don't invoke a syscall in uncongested cases. Switch over to it to reduce syscall number.

sys_sem semaphores don't invoke a syscall in uncongested cases.
Switch over to it to reduce syscall number.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup, we probably want to use sys_sem in other places too and if so we could put the macros in a header for easier sharing.

@softwarecki
Copy link
Collaborator

The sys_sem object embeds a k_futex, so the syscall and k_object_find usage remain analogous to the previous implementation. There is an optimization because the syscall is invoked only when the calling thread must sleep while waiting for the semaphore to become available, which avoids syscall overhead in the uncontended fast path. Additionally, when userspace is disabled, the code falls back to using k_sem directly. The change therefore looks beneficial.

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.

3 participants