Lines Matching +full:line +full:- +full:idle +full:- +full:low

4  * SPDX-License-Identifier: Apache-2.0
51 #define K_PRIO_COOP(x) (-(CONFIG_NUM_COOP_PRIORITIES - (x)))
54 #define K_HIGHEST_THREAD_PRIO (-CONFIG_NUM_COOP_PRIORITIES)
58 #define K_LOWEST_APPLICATION_THREAD_PRIO (K_LOWEST_THREAD_PRIO - 1)
165 * Thread user options. May be needed by assembly code. Common part uses low
166 * bits, arch-specific use high bits.
212 * from within a user-provided callback they have been invoked.
213 * Effectively it serves as a tiny bit of zero-overhead TLS data.
265 /* end - thread options */
272 * - @ref K_USER allocate a userspace thread (requires `CONFIG_USERSPACE=y`)
290 * @retval -EBUSY if the thread stack is in use.
291 * @retval -EINVAL if @p stack is invalid.
292 * @retval -ENOSYS if dynamic thread stack allocation is disabled
308 * Thread options are architecture-specific, and can include K_ESSENTIAL,
315 * - K_THREAD_STACK_DEFINE() - For stacks that may support either user or
317 * - K_KERNEL_STACK_DEFINE() - For stacks that may support supervisor
323 * - The original size value passed to K_THREAD_STACK_DEFINE() or
325 * - The return value of K_THREAD_STACK_SIZEOF(stack) if the stack was
327 * - The return value of K_KERNEL_STACK_SIZEOF(stack) if the stack was
356 * This allows a supervisor thread to be re-used as a user thread.
361 * Any thread-local storage will be reverted to a pristine state.
366 * A common use of this function is to re-use the main thread as a user thread
367 * once all supervisor mode-only tasks have been completed.
411 thread->resource_pool = heap; in k_thread_heap_assign()
429 * @return -EBADF Bad thread object (user mode only)
430 * @return -EPERM No permissions on thread object (user mode only)
431 * #return -ENOTSUP Forbidden by hardware policy
432 * @return -EINVAL Thread is uninitialized or exited (user mode only)
433 * @return -EFAULT Bad memory address for unused_ptr (user mode only)
459 * to being aborted, self-exiting, or taking a fatal error. This API returns
469 * @retval -EBUSY returned without waiting
470 * @retval -EAGAIN waiting period timed out
471 * @retval -EDEADLK target thread is joining on the caller, or target thread
529 * @note The clock used for the microsecond-resolution delay here may
548 * being run from the idle thread.
600 /* Thread-local cache of current thread ID, set in z_thread_entry() */ in k_current_get()
663 return z_timeout_expires(&t->base.timeout); in z_impl_k_thread_timeout_expires_ticks()
678 return z_timeout_remaining(&t->base.timeout); in z_impl_k_thread_timeout_remaining_ticks()
707 #define Z_THREAD_INIT_DELAY(thread) SYS_TIMEOUT_MS((thread)->init_delay_ms)
710 #define Z_THREAD_INIT_DELAY(thread) (thread)->init_delay
755 * Thread options are architecture-specific, and can include K_ESSENTIAL,
793 * Thread options are architecture-specific, and can include K_ESSENTIAL,
806 * or in power-of-two size (if MPU).
844 * - If its priority is raised above the priority of the caller of this
847 * - If the caller operates on itself, it lowers its priority below that of
851 * Priority can be assigned in the range of -CONFIG_NUM_COOP_PRIORITIES to
852 * CONFIG_NUM_PREEMPT_PRIORITIES-1, where -CONFIG_NUM_COOP_PRIORITIES is the
878 * a signed non-negative quantity). Failure to adhere to this rule
1000 * @brief Set time-slicing period and scope.
1005 * To enable time slicing, @a slice must be non-zero. The scheduler
1032 * thread. When non-zero, this timeslice will take precedence over
1036 * will be called before the thread is removed/re-added to the run
1039 * currently-executing ISR. Such a callback is free to, for example,
1048 * @note Threads with a non-zero slice time set will be timesliced
1057 * fine-grained timing decisions within this callback should use the
1095 * - The code is running in a thread, not at ISR.
1096 * - The thread's priority is in the preemptible range.
1097 * - The thread has not locked the scheduler.
1102 * @return Non-zero if invoked by a preemptible thread.
1107 * @brief Test whether startup is in the before-main-task phase.
1114 * @return true if invoked before post-kernel initialization
1115 * @return false if invoked during/after post-kernel initialization
1140 * again becomes the current thread, its non-preemptible status is maintained.
1145 * extremely fast for non-userspace threads (just one byte
1155 * In general this is a historical API not well-suited to modern
1176 * upon which to build thread-local storage.
1201 * @retval -EFAULT Memory access error with supplied string
1202 * @retval -ENOSYS Thread name configuration option not enabled
1203 * @retval -EINVAL Thread name too long
1223 * @retval -ENOSPC Destination buffer too small
1224 * @retval -EFAULT Memory access error
1225 * @retval -ENOSYS Thread name feature not enabled
1458 * dynamic timer allocation. timeout.node is used in the double-linked
1478 /* user-specific data, also used to support legacy features */
1531 * callable from interrupt context (isr-ok).
1620 * This routine blocks the calling thread until the timer's status is non-zero
1622 * or the timer is stopped. If the timer status is already non-zero,
1653 return z_timeout_expires(&timer->timeout); in z_impl_k_timer_expires_ticks()
1668 return z_timeout_remaining(&timer->timeout); in z_impl_k_timer_remaining_ticks()
1689 * @brief Associate user-specific data with a timer.
1708 timer->user_data = user_data; in z_impl_k_timer_user_data_set()
1712 * @brief Retrieve the user-specific data from a timer.
1722 return timer->user_data; in z_impl_k_timer_user_data_get()
1763 * @brief Get system uptime (32-bit version).
1772 * interrupt blocking and 64-bit math.
1779 * @return The low 32 bits of the current uptime, in milliseconds.
1802 delta = uptime - *reftime; in k_uptime_delta()
1814 * @return Current hardware clock up-counter (in cycles).
1822 * @brief Read the 64-bit hardware clock.
1824 * This routine returns the current time in 64-bits, as measured by the
1829 * @return Current hardware clock up-counter (in cycles).
1834 __ASSERT(0, "64-bit cycle counter not enabled on this platform. " in k_cycle_get_64()
1893 * -EINTR and K_POLL_STATE_CANCELLED state (and per above, subsequent
1930 * @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
1962 * @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
1985 * The data items must be in a singly-linked list, with the first word
1987 * NULL-terminated.
1992 * @param head Pointer to first node in singly-linked list.
1993 * @param tail Pointer to last node in singly-linked list.
1996 * @retval -EINVAL on invalid supplied data
2005 * The data items must be in a singly-linked list implemented using a
2014 * @retval -EINVAL on invalid data
2029 * @param timeout Non-negative waiting period to obtain a data item
2082 * @return Non-zero if the queue is empty.
2089 return (int)sys_sflist_is_empty(&queue->data_q); in z_impl_k_queue_is_empty()
2175 * @param timeout Non-negative waiting period on the futex, or
2177 * @retval -EACCES Caller does not have read access to futex address.
2178 * @retval -EAGAIN If the futex value did not match the expected parameter.
2179 * @retval -EINVAL Futex parameter address not recognized by the kernel.
2180 * @retval -ETIMEDOUT Thread woke up due to timeout and not a futex wakeup.
2198 * @retval -EACCES Caller does not have access to the futex address.
2199 * @retval -EINVAL Futex parameter address not recognized by the kernel.
2315 * events that are expressed as bits in a single 32-bit word.
2339 * events that are expressed as bits in a single 32-bit word.
2420 k_queue_init(&(fifo)->_queue); \
2440 k_queue_cancel_wait(&(fifo)->_queue); \
2459 k_queue_append(&(fifo)->_queue, data); \
2477 * @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
2482 int fap_ret = k_queue_alloc_append(&(fifo)->_queue, data); \
2491 * The data items must be in a singly-linked list, with the first word of
2493 * NULL-terminated.
2498 * @param head Pointer to first node in singly-linked list.
2499 * @param tail Pointer to last node in singly-linked list.
2504 k_queue_append_list(&(fifo)->_queue, head, tail); \
2512 * The data items must be in a singly-linked list implemented using a
2514 * and must be re-initialized via sys_slist_init().
2524 k_queue_merge_slist(&(fifo)->_queue, list); \
2548 void *fg_ret = k_queue_get(&(fifo)->_queue, timeout); \
2563 * @return Non-zero if the FIFO queue is empty.
2567 k_queue_is_empty(&(fifo)->_queue)
2585 void *fph_ret = k_queue_peek_head(&(fifo)->_queue); \
2604 void *fpt_ret = k_queue_peek_tail(&(fifo)->_queue); \
2660 k_queue_init(&(lifo)->_queue); \
2681 k_queue_prepend(&(lifo)->_queue, data); \
2699 * @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
2704 int lap_ret = k_queue_alloc_prepend(&(lifo)->_queue, data); \
2729 void *lg_ret = k_queue_get(&(lifo)->_queue, timeout); \
2812 * @return -ENOMEM if memory couldn't be allocated
2827 * @retval -EAGAIN when object is still in use
2842 * @retval -ENOMEM if stack is full
2863 * @retval -EBUSY Returned without waiting.
2864 * @retval -EAGAIN Waiting period timed out.
2991 * @retval -EBUSY Returned without waiting.
2992 * @retval -EAGAIN Waiting period timed out.
3012 * @retval -EPERM The current thread does not own the mutex
3013 * @retval -EINVAL The mutex is not locked
3082 * @retval -EAGAIN Waiting period timed out.
3162 * @retval -EINVAL Invalid values
3182 * @retval -EBUSY Returned without waiting.
3183 * @retval -EAGAIN Waiting period timed out,
3205 * with -EAGAIN.
3227 return sem->count; in z_impl_k_sem_count_get()
3275 /** @brief Initialize a (non-delayable) work structure.
3279 * re-invoked to change the associated handler, but this must be done when the
3280 * work item is idle.
3293 * A zero return value indicates the work item appears to be idle.
3309 * Wrapper to determine whether a work item is in a non-idle dstate.
3318 * @return true if and only if k_work_busy_get() returns a non-zero value.
3335 * @retval -EBUSY
3339 * @retval -EINVAL if @p queue is null and the work item has never been run.
3340 * @retval -ENODEV if @p queue has not been started.
3355 /** @brief Wait for last-submitted instance to complete.
3377 * @retval false if work was already idle
3384 * This attempts to prevent a pending (non-delayable) work item from being
3409 * On return the work structure will be idle unless something submits it after
3449 * should not be re-invoked on a queue.
3516 * @retval -EALREADY if the work queue was not plugged.
3524 * can be re-invoked to change the associated handler, but this must be done
3525 * when the work item is idle.
3561 * be idle.
3567 * Wrapper to determine whether a delayed work item is in a non-idle state.
3576 * @return true if and only if k_work_delayable_busy_get() returns a non-zero
3614 /** @brief Submit an idle work item to a queue after a delay.
3616 * Unlike k_work_reschedule_for_queue() this is a no-op if the work item is
3632 * @retval -EBUSY if @p delay is @c K_NO_WAIT and
3634 * @retval -EINVAL if @p delay is @c K_NO_WAIT and
3636 * @retval -ENODEV if @p delay is @c K_NO_WAIT and
3643 /** @brief Submit an idle work item to the system work queue after a
3663 * (e.g. is idle, submitted, or running). This function does not affect
3687 * @retval -EBUSY if @p delay is @c K_NO_WAIT and
3689 * @retval -EINVAL if @p delay is @c K_NO_WAIT and
3691 * @retval -ENODEV if @p delay is @c K_NO_WAIT and
3735 * @retval false if work was already idle
3764 * Like k_work_cancel_delayable() but waits until the work becomes idle.
3785 * @retval true if work was not idle (call had to wait for cancellation of a
3839 * Accessed via k_work_busy_get(). May co-occur with other flags.
3845 * Accessed via k_work_busy_get(). May co-occur with other flags.
3852 * Accessed via k_work_busy_get(). May co-occur with other flags.
3859 * Accessed via k_work_busy_get(). May co-occur with other flags.
3912 * @brief Initialize a statically-defined delayable work item.
3914 * This macro can be used to initialize a statically-defined delayable
3950 * When a cancelling work item goes idle any matching waiters are
3973 * is generally not coherent. be stack-allocated. Violations are detected by
4023 /* Wait queue for idle work thread. */
4055 return z_timeout_expires(&dwork->timeout); in k_work_delayable_expires_get()
4061 return z_timeout_remaining(&dwork->timeout); in k_work_delayable_remaining_get()
4066 return &queue->thread; in k_work_queue_thread_get()
4112 #if defined(__cplusplus) && ((__cplusplus - 0) < 202002L)
4124 * @brief Initialize a statically-defined user work item.
4126 * This macro can be used to initialize a statically-defined user work
4170 return atomic_test_bit(&work->flags, K_WORK_USER_STATE_PENDING); in k_work_user_is_pending()
4187 * @retval -EBUSY if the work item was already in some workqueue
4188 * @retval -ENOMEM if no memory for thread resource pool allocation
4194 int ret = -EBUSY; in k_work_user_submit_to_queue()
4196 if (!atomic_test_and_set_bit(&work->flags, in k_work_user_submit_to_queue()
4198 ret = k_queue_alloc_append(&work_q->queue, work); in k_work_user_submit_to_queue()
4204 atomic_clear_bit(&work->flags, in k_work_user_submit_to_queue()
4248 return &work_q->thread; in k_work_user_queue_thread_get()
4278 * @brief Initialize a statically-defined work item.
4280 * This macro can be used to initialize a statically-defined workqueue work
4315 * to race conditions with the pre-existing triggered work item and work queue,
4334 * @retval -EINVAL Work item is being processed or has completed its work.
4335 * @retval -EADDRINUSE Work item is pending on a different workqueue.
4355 * to race conditions with the pre-existing triggered work item and work queue,
4371 * @retval -EINVAL Work item is being processed or has completed its work.
4372 * @retval -EADDRINUSE Work item is pending on a different workqueue.
4391 * @retval -EINVAL Work item is being processed or has completed its work.
4532 * @return 0 on success, -ENOMEM if there was insufficient memory in the
4533 * thread's resource pool, or -EINVAL if the size parameters cause
4547 * @retval -EBUSY Queue not empty
4564 * @param timeout Non-negative waiting period to add the message,
4569 * @retval -ENOMSG Returned without waiting or queue purged.
4570 * @retval -EAGAIN Waiting period timed out.
4591 * @retval -ENOMSG Returned without waiting.
4592 * @retval -EAGAIN Waiting period timed out.
4608 * @retval -ENOMSG Returned when the queue has no message.
4626 * @retval -ENOMSG Returned when the queue has no message at index.
4635 * message queue are unblocked and see an -ENOMSG error code.
4667 return msgq->max_msgs - msgq->used_msgs; in z_impl_k_msgq_num_free_get()
4683 return msgq->used_msgs; in z_impl_k_msgq_num_used_get()
4699 /** internal use only - needed for legacy API support */
4703 /** application-defined information value */
4711 /** internal use only - thread waiting on send (may be a dummy) */
4714 /** internal use only - semaphore used during asynchronous send */
4775 * receive and process it. The message data may be in a buffer or non-existent
4787 * @retval -ENOMSG Returned without waiting.
4788 * @retval -EAGAIN Waiting period timed out.
4797 * to process it. The message data may be in a buffer or non-existent
4823 * @retval -ENOMSG Returned without waiting.
4824 * @retval -EAGAIN Waiting period timed out.
4943 * @retval -EAGAIN nothing to cleanup
4960 * @retval -ENOMEM if memory couldn't be allocated
4978 * @retval -EIO Returned without waiting; zero data bytes were written.
4979 * @retval -EAGAIN Waiting period timed out; between zero and @a min_xfer
5000 * @retval -EINVAL invalid parameters supplied
5001 * @retval -EIO Returned without waiting; zero data bytes were read.
5002 * @retval -EAGAIN Waiting period timed out; between zero and @a min_xfer
5105 * @brief Statically define and initialize a memory slab in a public (non-static) scope.
5109 * @a slab_align -byte boundary. To ensure that each memory block is similarly
5119 * If such a use-case is desired, use @ref K_MEM_SLAB_DEFINE_STATIC
5140 * @a slab_align -byte boundary. To ensure that each memory block is similarly
5164 * N-byte boundary matching a word boundary, where N is a power of 2
5165 * (i.e. 4 on 32-bit systems, 8, 16, ...).
5175 * @retval -EINVAL invalid data supplied
5193 * @param timeout Non-negative waiting period to wait for operation to complete.
5199 * @retval -ENOMEM Returned without waiting.
5200 * @retval -EAGAIN Waiting period timed out.
5201 * @retval -EINVAL Invalid data supplied
5229 return slab->info.num_used; in k_mem_slab_num_used_get()
5245 return slab->info.max_used; in k_mem_slab_max_used_get()
5264 return slab->info.num_blocks - slab->info.num_used; in k_mem_slab_num_free_get()
5276 * @retval -EINVAL Any parameter points to NULL
5290 * @retval -EINVAL Memory slab is NULL
5328 * is a multiple of the specified power-of-two alignment value in
5382 /* Hand-calculated minimum heap sizes needed to return a successful
5383 * 1-byte allocation. See details in lib/os/heap.[ch]
5464 * difference is that k_aligned_alloc() accepts any non-zero @p size,
5470 * The aligned_alloc function (p: 347-348)
5519 /* polling API - PRIVATE */
5522 #define _INIT_OBJ_POLL_EVENT(obj) do { (obj)->poll_event = NULL; } while (false)
5527 /* private - types bit positions */
5550 #define Z_POLL_TYPE_BIT(type) (1U << ((type) - 1U))
5552 /* private - states bit positions */
5578 #define Z_POLL_STATE_BIT(state) (1U << ((state) - 1U))
5581 (32 - (0 \
5588 /* end of polling API - PRIVATE */
5599 /* public - values for k_poll_event.type bitfield */
5608 /* public - polling modes */
5616 /* public - values for k_poll_event.state bitfield */
5626 /* public - poll signal object */
5628 /** PRIVATE - DO NOT TOUCH */
5652 /** PRIVATE - DO NOT TOUCH */
5655 /** PRIVATE - DO NOT TOUCH */
5658 /** optional user-specified tag, opaque, untouched by the API */
5661 /** bitfield of event types (bitwise-ORed K_POLL_TYPE_xxx values) */
5664 /** bitfield of event states (bitwise-ORed K_POLL_STATE_xxx values) */
5670 /** unused bits in 32-bit word */
5673 /** per-type data */
5763 * @retval -EAGAIN Waiting period timed out.
5764 * @retval -EINTR Polling has been interrupted, e.g. with
5767 * words, -EINTR status means that at least one of output events is
5769 * @retval -ENOMEM Thread resource pool insufficient memory (user mode only)
5770 * @retval -EINVAL Bad parameters (user mode only)
5827 * @retval -EAGAIN The polling thread's timeout is in the process of expiring.
5840 * @brief Make the CPU idle.
5842 * This function makes the CPU idle until an event wakes it up.
5844 * In a regular system, the idle thread should be the only thread responsible
5845 * for making the CPU idle and triggering any type of power management.
5846 * However, in some more constrained systems, such as a single-threaded system,
5858 * @brief Make the CPU idle in an atomic fashion.
5862 * Enabling interrupts and entering a low-power mode will be atomic,
5864 * the processor enters a low-power mode.
5866 * After waking up from the low-power mode, the interrupt lockout state will
5899 * the oops occurred, so print file and line number before we jump into
5994 * @retval -ENOTSUP If the floating point disabling is not implemented.
5995 * -EINVAL If the floating point disabling could not be performed.
6019 * - K_FP_REGS indicates x87 FPU and MMX registers only
6020 * - K_SSE_REGS indicates SSE registers (and also x87 FPU and MMX registers)
6034 * @retval -ENOTSUP If the floating point enabling is not implemented.
6035 * -EINVAL If the floating point enabling could not be performed.
6044 * @return -EINVAL if null pointers, otherwise 0
6053 * @return -EINVAL if null pointers, otherwise 0
6064 * @return -EINVAL if invalid thread ID, otherwise 0
6075 * @return -EINVAL if invalid thread ID, otherwise 0