schedule: zephyr_ll: convert pdata->sem into sys_sem#10997
Conversation
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>
|
For context, part of changes in #10558 |
There was a problem hiding this comment.
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::semfromstruct k_semtostruct sys_sem, and migrate give/take/init calls tosys_sem_*(). - Add an include for
<zephyr/sys/sem.h>in the LL scheduler implementation. - Add POSIX no-op
sys_semtype + helpers (stubs) underposix/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. |
| /* 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; | ||
| } | ||
|
|
There was a problem hiding this comment.
This is ok, this is adding a stub for other users. zephyr_ll.c doesn't need this.
| unsigned int limit) | ||
| { | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
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.