poll: Enable multiple threads to use k_poll in the same object
This is necessary in order for k_queue_get to work properly since that is used with buffer pools which might be used by multiple threads asking for buffers. Jira: ZEP-2553 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
7725fc07e3
commit
7d01c5ecb7
9 changed files with 113 additions and 115 deletions
|
@ -51,8 +51,9 @@ void k_queue_init(struct k_queue *queue)
|
|||
{
|
||||
sys_slist_init(&queue->data_q);
|
||||
sys_dlist_init(&queue->wait_q);
|
||||
|
||||
_INIT_OBJ_POLL_EVENT(queue);
|
||||
#if defined(CONFIG_POLL)
|
||||
sys_dlist_init(&queue->poll_events);
|
||||
#endif
|
||||
|
||||
SYS_TRACING_OBJ_INIT(k_queue, queue);
|
||||
}
|
||||
|
@ -67,13 +68,12 @@ static void prepare_thread_to_run(struct k_thread *thread, void *data)
|
|||
#endif /* CONFIG_POLL */
|
||||
|
||||
/* returns 1 if a reschedule must take place, 0 otherwise */
|
||||
static inline int handle_poll_event(struct k_queue *queue)
|
||||
static inline int handle_poll_events(struct k_queue *queue)
|
||||
{
|
||||
#ifdef CONFIG_POLL
|
||||
u32_t state = K_POLL_STATE_DATA_AVAILABLE;
|
||||
|
||||
return queue->poll_event ?
|
||||
_handle_obj_poll_event(&queue->poll_event, state) : 0;
|
||||
return _handle_obj_poll_events(&queue->poll_events, state);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -95,7 +95,7 @@ void k_queue_cancel_wait(struct k_queue *queue)
|
|||
}
|
||||
}
|
||||
#else
|
||||
if (handle_poll_event(queue)) {
|
||||
if (handle_poll_events(queue)) {
|
||||
(void)_Swap(key);
|
||||
return;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ void k_queue_insert(struct k_queue *queue, void *prev, void *data)
|
|||
sys_slist_insert(&queue->data_q, prev, data);
|
||||
|
||||
#if defined(CONFIG_POLL)
|
||||
if (handle_poll_event(queue)) {
|
||||
if (handle_poll_events(queue)) {
|
||||
(void)_Swap(key);
|
||||
return;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ void k_queue_append_list(struct k_queue *queue, void *head, void *tail)
|
|||
}
|
||||
#else
|
||||
sys_slist_append_list(&queue->data_q, head, tail);
|
||||
if (handle_poll_event(queue)) {
|
||||
if (handle_poll_events(queue)) {
|
||||
(void)_Swap(key);
|
||||
return;
|
||||
}
|
||||
|
@ -206,11 +206,10 @@ static void *k_queue_poll(struct k_queue *queue, s32_t timeout)
|
|||
event.state = K_POLL_STATE_NOT_READY;
|
||||
|
||||
err = k_poll(&event, 1, timeout);
|
||||
if (err == -EAGAIN) {
|
||||
if (err) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__ASSERT_NO_MSG(err == 0);
|
||||
__ASSERT_NO_MSG(event.state == K_POLL_STATE_FIFO_DATA_AVAILABLE);
|
||||
|
||||
return sys_slist_get(&queue->data_q);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue