Skip to content

Conversation

@fei315412-cmyk
Copy link

One thread calls mpsc_pbuf_alloc to produce data, which invokes add_skip_item and steps into k_sem_take.

Another thread calls mpsc_pbuf_claim to consume data. In this condition, mpsc_pbuf_claim has only small remaining space and needs to call rd_idx_inc to reserve space, but there is still no data available.

The consumer should call k_sem_give to wake mpsc_pbuf_alloc again, so the producer can allocate space and continue producing data.

Without this wake-up, the producer thread may wait forever in k_sem_take, leading to a deadlock situation.

@zephyrbot zephyrbot added area: Tests Issues related to a particular existing or missing test area: Logging labels Nov 2, 2025
@fei315412-cmyk
Copy link
Author

@nordic-krch
run in qemu_x86 is good, run qemu_x86_64/atom is bad, how to used gdb ?
west build -p -b qemu_x86_64/atom tests/lib/mpsc_pbuf -T libraries.mpsc_pbuf.concurrent
west build -t run

@fei315412-cmyk
Copy link
Author

image this case easy find in native_sim and qemu_x86 and other platform sometimes happen.
One thread calls mpsc_pbuf_alloc to produce data, which invokes add_skip_item and steps into k_sem_take. Another thread calls mpsc_pbuf_claim to consume data. In this condition, mpsc_pbuf_claim has only small remaining space and needs to call rd_idx_inc to reserve space, but there is still no data available. The consumer should call k_sem_give to wake mpsc_pbuf_alloc again, so the producer can allocate space and continue producing data. Without this wake-up, the producer thread may wait forever in k_sem_take, leading to a deadlock situation. Signed-off-by: Fei Wang <fei.wang@jaguarmicro.com>
@fei315412-cmyk
Copy link
Author

@kartben manual trigger Twister Status / all jobs . thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Logging area: Tests Issues related to a particular existing or missing test

3 participants