Lines Matching refs:queue
171 static void queue_flusher_locked(struct k_work_q *queue, in queue_flusher_locked() argument
179 SYS_SLIST_FOR_EACH_CONTAINER(&queue->pending, wn, node) { in queue_flusher_locked()
188 sys_slist_insert(&queue->pending, &work->node, in queue_flusher_locked()
191 sys_slist_prepend(&queue->pending, &flusher->work.node); in queue_flusher_locked()
202 static inline void queue_remove_locked(struct k_work_q *queue, in queue_remove_locked() argument
206 (void)sys_slist_find_and_remove(&queue->pending, &work->node); in queue_remove_locked()
221 static inline bool notify_queue_locked(struct k_work_q *queue) in notify_queue_locked() argument
225 if (queue != NULL) { in notify_queue_locked()
226 rv = z_sched_wake(&queue->notifyq, 0, NULL); in notify_queue_locked()
251 static inline int queue_submit_locked(struct k_work_q *queue, in queue_submit_locked() argument
254 if (queue == NULL) { in queue_submit_locked()
259 bool chained = (_current == &queue->thread) && !k_is_in_isr(); in queue_submit_locked()
260 bool draining = flag_test(&queue->flags, K_WORK_QUEUE_DRAIN_BIT); in queue_submit_locked()
261 bool plugged = flag_test(&queue->flags, K_WORK_QUEUE_PLUGGED_BIT); in queue_submit_locked()
270 if (!flag_test(&queue->flags, K_WORK_QUEUE_STARTED_BIT)) { in queue_submit_locked()
277 sys_slist_append(&queue->pending, &work->node); in queue_submit_locked()
279 (void)notify_queue_locked(queue); in queue_submit_locked()
326 *queuep = work->queue; in submit_to_queue_locked()
334 __ASSERT_NO_MSG(work->queue != NULL); in submit_to_queue_locked()
335 *queuep = work->queue; in submit_to_queue_locked()
345 work->queue = *queuep; in submit_to_queue_locked()
369 int z_work_submit_to_queue(struct k_work_q *queue, in z_work_submit_to_queue() argument
376 int ret = submit_to_queue_locked(work, &queue); in z_work_submit_to_queue()
383 int k_work_submit_to_queue(struct k_work_q *queue, in k_work_submit_to_queue() argument
386 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_work, submit_to_queue, queue, work); in k_work_submit_to_queue()
388 int ret = z_work_submit_to_queue(queue, work); in k_work_submit_to_queue()
399 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_work, submit_to_queue, queue, work, ret); in k_work_submit_to_queue()
437 struct k_work_q *queue = work->queue; in work_flush_locked() local
439 __ASSERT_NO_MSG(queue != NULL); in work_flush_locked()
441 queue_flusher_locked(queue, work, flusher); in work_flush_locked()
442 notify_queue_locked(queue); in work_flush_locked()
496 queue_remove_locked(work->queue, work); in cancel_async_locked()
601 struct k_work_q *queue = (struct k_work_q *)workq_ptr; in work_queue_main() local
611 node = sys_slist_get(&queue->pending); in work_queue_main()
616 flag_set(&queue->flags, K_WORK_QUEUE_BUSY_BIT); in work_queue_main()
634 } else if (flag_test_and_clear(&queue->flags, in work_queue_main()
645 (void)z_sched_wake_all(&queue->drainq, 1, NULL); in work_queue_main()
660 (void)z_sched_wait(&lock, key, &queue->notifyq, in work_queue_main()
682 flag_clear(&queue->flags, K_WORK_QUEUE_BUSY_BIT); in work_queue_main()
683 yield = !flag_test(&queue->flags, K_WORK_QUEUE_NO_YIELD_BIT); in work_queue_main()
695 void k_work_queue_init(struct k_work_q *queue) in k_work_queue_init() argument
697 __ASSERT_NO_MSG(queue != NULL); in k_work_queue_init()
699 *queue = (struct k_work_q) { in k_work_queue_init()
703 SYS_PORT_TRACING_OBJ_INIT(k_work_queue, queue); in k_work_queue_init()
706 void k_work_queue_start(struct k_work_q *queue, in k_work_queue_start() argument
712 __ASSERT_NO_MSG(queue); in k_work_queue_start()
714 __ASSERT_NO_MSG(!flag_test(&queue->flags, K_WORK_QUEUE_STARTED_BIT)); in k_work_queue_start()
717 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_work_queue, start, queue); in k_work_queue_start()
719 sys_slist_init(&queue->pending); in k_work_queue_start()
720 z_waitq_init(&queue->notifyq); in k_work_queue_start()
721 z_waitq_init(&queue->drainq); in k_work_queue_start()
731 flags_set(&queue->flags, flags); in k_work_queue_start()
733 (void)k_thread_create(&queue->thread, stack, stack_size, in k_work_queue_start()
734 work_queue_main, queue, NULL, NULL, in k_work_queue_start()
738 k_thread_name_set(&queue->thread, cfg->name); in k_work_queue_start()
741 k_thread_start(&queue->thread); in k_work_queue_start()
743 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_work_queue, start, queue); in k_work_queue_start()
746 int k_work_queue_drain(struct k_work_q *queue, in k_work_queue_drain() argument
749 __ASSERT_NO_MSG(queue); in k_work_queue_drain()
752 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_work_queue, drain, queue); in k_work_queue_drain()
757 if (((flags_get(&queue->flags) in k_work_queue_drain()
760 || !sys_slist_is_empty(&queue->pending)) { in k_work_queue_drain()
761 flag_set(&queue->flags, K_WORK_QUEUE_DRAIN_BIT); in k_work_queue_drain()
763 flag_set(&queue->flags, K_WORK_QUEUE_PLUGGED_BIT); in k_work_queue_drain()
766 notify_queue_locked(queue); in k_work_queue_drain()
767 ret = z_sched_wait(&lock, key, &queue->drainq, in k_work_queue_drain()
773 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_work_queue, drain, queue, ret); in k_work_queue_drain()
778 int k_work_queue_unplug(struct k_work_q *queue) in k_work_queue_unplug() argument
780 __ASSERT_NO_MSG(queue); in k_work_queue_unplug()
782 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_work_queue, unplug, queue); in k_work_queue_unplug()
787 if (flag_test_and_clear(&queue->flags, K_WORK_QUEUE_PLUGGED_BIT)) { in k_work_queue_unplug()
793 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_work_queue, unplug, queue, ret); in k_work_queue_unplug()
812 struct k_work_q *queue = NULL; in work_timeout() local
822 queue = dw->queue; in work_timeout()
823 (void)submit_to_queue_locked(wp, &queue); in work_timeout()
895 dwork->queue = *queuep; in schedule_for_queue_locked()
950 int k_work_schedule_for_queue(struct k_work_q *queue, in k_work_schedule_for_queue() argument
956 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_work, schedule_for_queue, queue, dwork, delay); in k_work_schedule_for_queue()
964 ret = schedule_for_queue_locked(&queue, dwork, delay); in k_work_schedule_for_queue()
969 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_work, schedule_for_queue, queue, dwork, delay, ret); in k_work_schedule_for_queue()
986 int k_work_reschedule_for_queue(struct k_work_q *queue, in k_work_reschedule_for_queue() argument
992 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_work, reschedule_for_queue, queue, dwork, delay); in k_work_reschedule_for_queue()
1001 ret = schedule_for_queue_locked(&queue, dwork, delay); in k_work_reschedule_for_queue()
1005 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_work, reschedule_for_queue, queue, dwork, delay, ret); in k_work_reschedule_for_queue()
1099 struct k_work_q *queue = dwork->queue; in k_work_flush_delayable() local
1101 (void)submit_to_queue_locked(work, &queue); in k_work_flush_delayable()