Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/os/mpsc_pbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ const union mpsc_pbuf_generic *mpsc_pbuf_claim(struct mpsc_pbuf_buffer *buffer)
{
union mpsc_pbuf_generic *item;
bool cont;
#ifdef CONFIG_MULTITHREADING
bool need_post = false;
#endif

do {
uint32_t a;
Expand All @@ -562,6 +565,9 @@ const union mpsc_pbuf_generic *mpsc_pbuf_claim(struct mpsc_pbuf_buffer *buffer)
idx_inc(buffer, buffer->tmp_rd_idx, inc);
rd_idx_inc(buffer, inc);
cont = true;
#ifdef CONFIG_MULTITHREADING
need_post = true;
#endif
} else {
item->hdr.busy = 1;
buffer->tmp_rd_idx =
Expand All @@ -576,6 +582,11 @@ const union mpsc_pbuf_generic *mpsc_pbuf_claim(struct mpsc_pbuf_buffer *buffer)
k_spin_unlock(&buffer->lock, key);
} while (cont);

#ifdef CONFIG_MULTITHREADING
if (need_post && item == NULL) {
k_sem_give(&buffer->sem);
}
#endif
return item;
}

Expand Down