Lines Matching +full:has +full:- +full:lock
4 * SPDX-License-Identifier: Apache-2.0
22 th->base.prio = item->priority; in set_prio()
23 th->base.prio_deadline = item->deadline; in set_prio()
31 if (aw->priority != bw->priority) { in rb_lessthan()
32 return aw->priority > bw->priority; in rb_lessthan()
35 if (aw->deadline != bw->deadline) { in rb_lessthan()
36 return aw->deadline - bw->deadline > 0; in rb_lessthan()
44 th->base.user_options |= K_CALLBACK_STATE; in thread_set_requeued()
49 th->base.user_options &= ~K_CALLBACK_STATE; in thread_clear_requeued()
54 return !!(th->base.user_options & K_CALLBACK_STATE); in thread_was_requeued()
64 if (a->priority > b->priority) { in item_lessthan()
66 } else if ((a->priority == b->priority) && in item_lessthan()
67 (a->deadline != b->deadline)) { in item_lessthan()
68 return a->deadline - b->deadline > 0; in item_lessthan()
80 k_spinlock_key_t k = k_spin_lock(&queue->lock); in p4wq_loop()
83 struct rbnode *r = rb_get_max(&queue->queue); in p4wq_loop()
89 rb_remove(&queue->queue, r); in p4wq_loop()
90 w->thread = arch_current_thread(); in p4wq_loop()
91 sys_dlist_append(&queue->active, &w->dlnode); in p4wq_loop()
95 k_spin_unlock(&queue->lock, k); in p4wq_loop()
97 w->handler(w); in p4wq_loop()
99 k = k_spin_lock(&queue->lock); in p4wq_loop()
105 sys_dlist_remove(&w->dlnode); in p4wq_loop()
106 w->thread = NULL; in p4wq_loop()
107 k_sem_give(&w->done_sem); in p4wq_loop()
110 z_pend_curr(&queue->lock, k, &queue->waitq, K_FOREVER); in p4wq_loop()
111 k = k_spin_lock(&queue->lock); in p4wq_loop()
119 if (work->sync) { in k_p4wq_wait()
120 return k_sem_take(&work->done_sem, timeout); in k_p4wq_wait()
123 return k_sem_count_get(&work->done_sem) ? 0 : -EBUSY; in k_p4wq_wait()
129 z_waitq_init(&queue->waitq); in k_p4wq_init()
130 queue->queue.lessthan_fn = rb_lessthan; in k_p4wq_init()
131 sys_dlist_init(&queue->active); in k_p4wq_init()
141 queue->flags & K_P4WQ_DELAYED_START ? K_FOREVER : K_NO_WAIT); in k_p4wq_add_thread()
148 for (int i = 0; i < pp->num; i++) { in static_init()
149 uintptr_t ssz = K_THREAD_STACK_LEN(pp->stack_size); in static_init()
150 struct k_p4wq *q = pp->flags & K_P4WQ_QUEUE_PER_THREAD ? in static_init()
151 pp->queue + i : pp->queue; in static_init()
153 if (!i || (pp->flags & K_P4WQ_QUEUE_PER_THREAD)) { in static_init()
157 q->flags = pp->flags; in static_init()
161 * delay starting threads until that has been done in static_init()
163 if (q->flags & K_P4WQ_USER_CPU_MASK) { in static_init()
164 q->flags |= K_P4WQ_DELAYED_START; in static_init()
167 k_p4wq_add_thread(q, &pp->threads[i], in static_init()
168 &pp->stacks[ssz * i], in static_init()
169 pp->stack_size); in static_init()
172 if (pp->flags & K_P4WQ_USER_CPU_MASK) { in static_init()
173 int ret = k_thread_cpu_mask_clear(&pp->threads[i]); in static_init()
190 if (queue->flags & K_P4WQ_USER_CPU_MASK) { in k_p4wq_enable_static_thread()
194 int ret = k_thread_cpu_mask_enable(thread, i - 1); in k_p4wq_enable_static_thread()
199 cpu_mask &= ~BIT(i - 1); in k_p4wq_enable_static_thread()
204 if (queue->flags & K_P4WQ_DELAYED_START) { in k_p4wq_enable_static_thread()
217 k_spinlock_key_t k = k_spin_lock(&queue->lock); in k_p4wq_submit()
223 item->deadline += k_cycle_get_32(); in k_p4wq_submit()
226 if (item->thread == arch_current_thread()) { in k_p4wq_submit()
227 sys_dlist_remove(&item->dlnode); in k_p4wq_submit()
229 item->thread = NULL; in k_p4wq_submit()
231 k_sem_init(&item->done_sem, 0, 1); in k_p4wq_submit()
233 __ASSERT_NO_MSG(item->thread == NULL); in k_p4wq_submit()
235 rb_insert(&queue->queue, &item->rbnode); in k_p4wq_submit()
236 item->queue = queue; in k_p4wq_submit()
242 if (rb_get_max(&queue->queue) != &item->rbnode) { in k_p4wq_submit()
254 SYS_DLIST_FOR_EACH_CONTAINER(&queue->active, wi, dlnode) { in k_p4wq_submit()
256 * item_lessthan(a, b) == true means a has lower priority than b in k_p4wq_submit()
275 struct k_thread *th = z_unpend_first_thread(&queue->waitq); in k_p4wq_submit()
284 z_reschedule(&queue->lock, k); in k_p4wq_submit()
289 k_spin_unlock(&queue->lock, k); in k_p4wq_submit()
294 k_spinlock_key_t k = k_spin_lock(&queue->lock); in k_p4wq_cancel()
295 bool ret = rb_contains(&queue->queue, &item->rbnode); in k_p4wq_cancel()
298 rb_remove(&queue->queue, &item->rbnode); in k_p4wq_cancel()
299 k_sem_give(&item->done_sem); in k_p4wq_cancel()
302 k_spin_unlock(&queue->lock, k); in k_p4wq_cancel()