Skip to content

schedule: zephyr_ll: convert pdata->sem into sys_sem#10997

Open
kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202607-zephyrll-use-sys-sem
Open

schedule: zephyr_ll: convert pdata->sem into sys_sem#10997
kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202607-zephyrll-use-sys-sem

Conversation

@kv2019i

@kv2019i kv2019i commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Convert the pdata->sem into a sys_sem to make the code compatible with userspace LL builds. Using sys_sem allows access control to be based on access to zephyr_ll_pdata object and works both from kernel and user-space.

Add POSIX no-op stubs for sys_sem to maintain testbench build compatibility.

Convert the pdata->sem into a sys_sem to make the code
compatible with userspace LL builds. Using sys_sem allows
access control to be based on access to zephyr_ll_pdata
object and works both from kernel and user-space.

Add POSIX no-op stubs for sys_sem to maintain testbench build
compatibility.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Copilot AI review requested due to automatic review settings July 14, 2026 15:41
@kv2019i

kv2019i commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

For context, part of changes in #10558

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Zephyr low-latency (LL) scheduler to use sys_sem instead of k_sem for per-task synchronization, aiming to support userspace LL builds by making access control depend on access to the zephyr_ll_pdata object. It also adds POSIX-side no-op sys_sem stubs intended to keep non-Zephyr/testbench builds compiling.

Changes:

  • Switch zephyr_ll_pdata::sem from struct k_sem to struct sys_sem, and migrate give/take/init calls to sys_sem_*().
  • Add an include for <zephyr/sys/sem.h> in the LL scheduler implementation.
  • Add POSIX no-op sys_sem type + helpers (stubs) under posix/include/rtos/mutex.h.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/schedule/zephyr_ll.c Migrates LL task semaphore from k_sem to sys_sem and updates call sites.
posix/include/rtos/mutex.h Adds POSIX no-op sys_sem declarations/helpers intended for testbench compatibility.

Comment on lines +65 to +85
/* provide a no-op implementation for zephyr/sys/sem.h */

struct sys_sem {
};

static inline int sys_sem_init(struct sys_sem *sem, unsigned int initial_count,
unsigned int limit)
{
return 0;
}

static inline int sys_sem_give(struct sys_sem *sem)
{
return 0;
}

static inline int sys_sem_take(struct sys_sem *sem, k_timeout_t timeout)
{
return 0;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is ok, this is adding a stub for other users. zephyr_ll.c doesn't need this.

unsigned int limit)
{
return 0;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

our testbench flows don't do any multiprocessing for now, right? No threads, no forks or clones. Wondering if recreating a thread model similar to the real one in it to test any deadlocks would be useful, but maybe it would be too different from the reality anyway.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ack @lyakh . The concurrency primitives are all no-ops now. OTOH, I think for any actual multiprocessing, we'd probably be better off using Zephyr posix target (like the fuzzer is using) and then we get proper mapping to posix interfaces via Zephyr. Not sure doing this wrapping (e.g. to POSIX pthreads) once more on SOF side seems is worth the effort...

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