Lines Matching +full:older +full:- +full:than +full:- +full:seconds
4 * SPDX-License-Identifier: Apache-2.0
54 #define K_PRIO_COOP(x) (-(CONFIG_NUM_COOP_PRIORITIES - (x)))
57 #define K_HIGHEST_THREAD_PRIO (-CONFIG_NUM_COOP_PRIORITIES)
61 #define K_LOWEST_APPLICATION_THREAD_PRIO (K_LOWEST_THREAD_PRIO - 1)
246 * bits, arch-specific use high bits.
290 * from within a user-provided callback they have been invoked.
291 * Effectively it serves as a tiny bit of zero-overhead TLS data.
329 /* end - thread options */
336 * - @ref K_USER allocate a userspace thread (requires `CONFIG_USERSPACE=y`)
354 * @retval -EBUSY if the thread stack is in use.
355 * @retval -EINVAL if @p stack is invalid.
356 * @retval -ENOSYS if dynamic thread stack allocation is disabled
372 * Thread options are architecture-specific, and can include K_ESSENTIAL,
379 * - K_THREAD_STACK_DEFINE() - For stacks that may support either user or
381 * - K_KERNEL_STACK_DEFINE() - For stacks that may support supervisor
387 * - The original size value passed to K_THREAD_STACK_DEFINE() or
389 * - The return value of K_THREAD_STACK_SIZEOF(stack) if the stack was
391 * - The return value of K_KERNEL_STACK_SIZEOF(stack) if the stack was
420 * This allows a supervisor thread to be re-used as a user thread.
425 * Any thread-local storage will be reverted to a pristine state.
430 * A common use of this function is to re-use the main thread as a user thread
431 * once all supervisor mode-only tasks have been completed.
475 thread->resource_pool = heap; in k_thread_heap_assign()
493 * @return -EBADF Bad thread object (user mode only)
494 * @return -EPERM No permissions on thread object (user mode only)
495 * #return -ENOTSUP Forbidden by hardware policy
496 * @return -EINVAL Thread is uninitialized or exited (user mode only)
497 * @return -EFAULT Bad memory address for unused_ptr (user mode only)
523 * to being aborted, self-exiting, or taking a fatal error. This API returns
533 * @retval -EBUSY returned without waiting
534 * @retval -EAGAIN waiting period timed out
535 * @retval -EDEADLK target thread is joining on the caller, or target thread
595 * @note The clock used for the microsecond-resolution delay here may
598 * less time than k_sleep(K_MSEC(1)), with the offset dependent on
667 /* Thread-local cache of current thread ID, set in z_thread_entry() */ in k_current_get()
714 return z_timeout_expires(&thread->base.timeout); in z_impl_k_thread_timeout_expires_ticks()
729 return z_timeout_remaining(&thread->base.timeout); in z_impl_k_thread_timeout_remaining_ticks()
758 #define Z_THREAD_INIT_DELAY(thread) SYS_TIMEOUT_MS((thread)->init_delay_ms)
761 #define Z_THREAD_INIT_DELAY(thread) (thread)->init_delay
806 * Thread options are architecture-specific, and can include K_ESSENTIAL,
844 * Thread options are architecture-specific, and can include K_ESSENTIAL,
857 * or in power-of-two size (if MPU).
895 * - If its priority is raised above the priority of a currently scheduled
898 * - If the caller lowers the priority of a currently scheduled preemptible
902 * Priority can be assigned in the range of -CONFIG_NUM_COOP_PRIORITIES to
903 * CONFIG_NUM_PREEMPT_PRIORITIES-1, where -CONFIG_NUM_COOP_PRIORITIES is the
928 * scheduler queue and the "last" deadline must be less than 2^31 (i.e
929 * a signed non-negative quantity). Failure to adhere to this rule
1096 * @brief Set time-slicing period and scope.
1101 * To enable time slicing, @a slice must be non-zero. The scheduler
1102 * ensures that no thread runs for more than the specified time limit
1104 * Any thread whose priority is higher than @a prio is exempted, and may
1128 * thread. When non-zero, this timeslice will take precedence over
1132 * will be called before the thread is removed/re-added to the run
1135 * currently-executing ISR. Such a callback is free to, for example,
1139 * @note Unlike the older API, the time slice parameter here is
1144 * @note Threads with a non-zero slice time set will be timesliced
1145 * always, even if they are higher priority than the maximum timeslice
1153 * fine-grained timing decisions within this callback should use the
1191 * - The code is running in a thread, not at ISR.
1192 * - The thread's priority is in the preemptible range.
1193 * - The thread has not locked the scheduler.
1198 * @return Non-zero if invoked by a preemptible thread.
1203 * @brief Test whether startup is in the before-main-task phase.
1210 * @return true if invoked before post-kernel initialization
1211 * @return false if invoked during/after post-kernel initialization
1236 * again becomes the current thread, its non-preemptible status is maintained.
1241 * extremely fast for non-userspace threads (just one byte
1251 * In general this is a historical API not well-suited to modern
1272 * upon which to build thread-local storage.
1297 * @retval -EFAULT Memory access error with supplied string
1298 * @retval -ENOSYS Thread name configuration option not enabled
1299 * @retval -EINVAL Thread name too long
1319 * @retval -ENOSPC Destination buffer too small
1320 * @retval -EFAULT Memory access error
1321 * @retval -ENOSYS Thread name feature not enabled
1425 * @brief Generate timeout delay from seconds.
1428 * to wait up to @a s seconds to perform the requested operation.
1430 * @param s Duration in seconds.
1554 * dynamic timer allocation. timeout.node is used in the double-linked
1574 /* user-specific data, also used to support legacy features */
1627 * callable from interrupt context (isr-ok).
1716 * This routine blocks the calling thread until the timer's status is non-zero
1718 * or the timer is stopped. If the timer status is already non-zero,
1749 return z_timeout_expires(&timer->timeout); in z_impl_k_timer_expires_ticks()
1767 return z_timeout_remaining(&timer->timeout); in z_impl_k_timer_remaining_ticks()
1788 * @brief Associate user-specific data with a timer.
1807 timer->user_data = user_data; in z_impl_k_timer_user_data_set()
1811 * @brief Retrieve the user-specific data from a timer.
1821 return timer->user_data; in z_impl_k_timer_user_data_get()
1862 * @brief Get system uptime (32-bit version).
1871 * interrupt blocking and 64-bit math.
1886 * @brief Get system uptime in seconds.
1889 * in seconds.
1891 * @return Current uptime in seconds.
1914 delta = uptime - *reftime; in k_uptime_delta()
1926 * @return Current hardware clock up-counter (in cycles).
1934 * @brief Read the 64-bit hardware clock.
1936 * This routine returns the current time in 64-bits, as measured by the
1941 * @return Current hardware clock up-counter (in cycles).
1946 __ASSERT(0, "64-bit cycle counter not enabled on this platform. " in k_cycle_get_64()
2005 * -EINTR and K_POLL_STATE_CANCELLED state (and per above, subsequent
2042 * @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
2074 * @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
2097 * The data items must be in a singly-linked list, with the first word
2099 * NULL-terminated.
2104 * @param head Pointer to first node in singly-linked list.
2105 * @param tail Pointer to last node in singly-linked list.
2108 * @retval -EINVAL on invalid supplied data
2117 * The data items must be in a singly-linked list implemented using a
2126 * @retval -EINVAL on invalid data
2193 * @return Non-zero if the queue is empty.
2200 return sys_sflist_is_empty(&queue->data_q) ? 1 : 0; in z_impl_k_queue_is_empty()
2288 * @retval -EACCES Caller does not have read access to futex address.
2289 * @retval -EAGAIN If the futex value did not match the expected parameter.
2290 * @retval -EINVAL Futex parameter address not recognized by the kernel.
2291 * @retval -ETIMEDOUT Thread woke up due to timeout and not a futex wakeup.
2309 * @retval -EACCES Caller does not have access to the futex address.
2310 * @retval -EINVAL Futex parameter address not recognized by the kernel.
2426 * events that are expressed as bits in a single 32-bit word.
2450 * events that are expressed as bits in a single 32-bit word.
2531 k_queue_init(&(fifo)->_queue); \
2551 k_queue_cancel_wait(&(fifo)->_queue); \
2571 k_queue_append(&(fifo)->_queue, _data); \
2589 * @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
2595 int fap_ret = k_queue_alloc_append(&(fifo)->_queue, _data); \
2604 * The data items must be in a singly-linked list, with the first word of
2606 * NULL-terminated.
2611 * @param head Pointer to first node in singly-linked list.
2612 * @param tail Pointer to last node in singly-linked list.
2617 k_queue_append_list(&(fifo)->_queue, head, tail); \
2625 * The data items must be in a singly-linked list implemented using a
2627 * and must be re-initialized via sys_slist_init().
2637 k_queue_merge_slist(&(fifo)->_queue, list); \
2661 void *fg_ret = k_queue_get(&(fifo)->_queue, timeout); \
2676 * @return Non-zero if the FIFO queue is empty.
2680 k_queue_is_empty(&(fifo)->_queue)
2698 void *fph_ret = k_queue_peek_head(&(fifo)->_queue); \
2717 void *fpt_ret = k_queue_peek_tail(&(fifo)->_queue); \
2773 k_queue_init(&(lifo)->_queue); \
2795 k_queue_prepend(&(lifo)->_queue, _data); \
2813 * @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
2819 int lap_ret = k_queue_alloc_prepend(&(lifo)->_queue, _data); \
2844 void *lg_ret = k_queue_get(&(lifo)->_queue, timeout); \
2927 * @return -ENOMEM if memory couldn't be allocated
2942 * @retval -EAGAIN when object is still in use
2957 * @retval -ENOMEM if stack is full
2978 * @retval -EBUSY Returned without waiting.
2979 * @retval -EAGAIN Waiting period timed out.
3106 * @retval -EBUSY Returned without waiting.
3107 * @retval -EAGAIN Waiting period timed out.
3127 * @retval -EPERM The current thread does not own the mutex
3128 * @retval -EINVAL The mutex is not locked
3197 * @retval -EAGAIN Waiting period timed out.
3277 * @retval -EINVAL Invalid values
3297 * @retval -EBUSY Returned without waiting.
3298 * @retval -EAGAIN Waiting period timed out,
3320 * with -EAGAIN.
3342 return sem->count; in z_impl_k_sem_count_get()
3390 /** @brief Initialize a (non-delayable) work structure.
3394 * re-invoked to change the associated handler, but this must be done when the
3424 * Wrapper to determine whether a work item is in a non-idle state.
3433 * @return true if and only if k_work_busy_get() returns a non-zero value.
3450 * @retval -EBUSY
3454 * @retval -EINVAL if @p queue is null and the work item has never been run.
3455 * @retval -ENODEV if @p queue has not been started.
3470 /** @brief Wait for last-submitted instance to complete.
3499 * This attempts to prevent a pending (non-delayable) work item from being
3564 * should not be re-invoked on a queue.
3631 * @retval -EALREADY if the work queue was not plugged.
3645 * @retval -EALREADY if the work queue was not started (or already stopped)
3646 * @retval -EBUSY if the work queue is actively processing work items
3647 * @retval -ETIMEDOUT if the work queue did not stop within the stipulated timeout
3655 * can be re-invoked to change the associated handler, but this must be done
3698 * Wrapper to determine whether a delayed work item is in a non-idle state.
3707 * @return true if and only if k_work_delayable_busy_get() returns a non-zero
3747 * Unlike k_work_reschedule_for_queue() this is a no-op if the work item is
3765 * @retval -EBUSY if @p delay is @c K_NO_WAIT and
3767 * @retval -EINVAL if @p delay is @c K_NO_WAIT and
3769 * @retval -ENODEV if @p delay is @c K_NO_WAIT and
3820 * @retval -EBUSY if @p delay is @c K_NO_WAIT and
3822 * @retval -EINVAL if @p delay is @c K_NO_WAIT and
3824 * @retval -ENODEV if @p delay is @c K_NO_WAIT and
3975 * Accessed via k_work_busy_get(). May co-occur with other flags.
3981 * Accessed via k_work_busy_get(). May co-occur with other flags.
3988 * Accessed via k_work_busy_get(). May co-occur with other flags.
3995 * Accessed via k_work_busy_get(). May co-occur with other flags.
4001 * Accessed via k_work_busy_get(). May co-occur with other flags.
4054 * @brief Initialize a statically-defined delayable work item.
4056 * This macro can be used to initialize a statically-defined delayable
4115 * is generally not coherent. be stack-allocated. Violations are detected by
4202 return z_timeout_expires(&dwork->timeout); in k_work_delayable_expires_get()
4208 return z_timeout_remaining(&dwork->timeout); in k_work_delayable_remaining_get()
4213 return &queue->thread; in k_work_queue_thread_get()
4259 #if defined(__cplusplus) && ((__cplusplus - 0) < 202002L)
4271 * @brief Initialize a statically-defined user work item.
4273 * This macro can be used to initialize a statically-defined user work
4317 return atomic_test_bit(&work->flags, K_WORK_USER_STATE_PENDING); in k_work_user_is_pending()
4334 * @retval -EBUSY if the work item was already in some workqueue
4335 * @retval -ENOMEM if no memory for thread resource pool allocation
4341 int ret = -EBUSY; in k_work_user_submit_to_queue()
4343 if (!atomic_test_and_set_bit(&work->flags, in k_work_user_submit_to_queue()
4345 ret = k_queue_alloc_append(&work_q->queue, work); in k_work_user_submit_to_queue()
4351 atomic_clear_bit(&work->flags, in k_work_user_submit_to_queue()
4395 return &work_q->thread; in k_work_user_queue_thread_get()
4425 * @brief Initialize a statically-defined work item.
4427 * This macro can be used to initialize a statically-defined workqueue work
4462 * to race conditions with the pre-existing triggered work item and work queue,
4481 * @retval -EINVAL Work item is being processed or has completed its work.
4482 * @retval -EADDRINUSE Work item is pending on a different workqueue.
4502 * to race conditions with the pre-existing triggered work item and work queue,
4518 * @retval -EINVAL Work item is being processed or has completed its work.
4519 * @retval -EADDRINUSE Work item is pending on a different workqueue.
4538 * @retval -EINVAL Work item is being processed or has completed its work.
4679 * @return 0 on success, -ENOMEM if there was insufficient memory in the
4680 * thread's resource pool, or -EINVAL if the size parameters cause
4694 * @retval -EBUSY Queue not empty
4715 * @retval -ENOMSG Returned without waiting or queue purged.
4716 * @retval -EAGAIN Waiting period timed out.
4737 * @retval -ENOMSG Returned without waiting or queue purged.
4738 * @retval -EAGAIN Waiting period timed out.
4754 * @retval -ENOMSG Returned when the queue has no message.
4772 * @retval -ENOMSG Returned when the queue has no message at index.
4781 * message queue are unblocked and see an -ENOMSG error code.
4813 return msgq->max_msgs - msgq->used_msgs; in z_impl_k_msgq_num_free_get()
4829 return msgq->used_msgs; in z_impl_k_msgq_num_used_get()
4847 /** application-defined information value */
4855 /** internal use only - thread waiting on send (may be a dummy) */
4858 /** internal use only - semaphore used during asynchronous send */
4919 * receive and process it. The message data may be in a buffer or non-existent
4931 * @retval -ENOMSG Returned without waiting.
4932 * @retval -EAGAIN Waiting period timed out.
4941 * to process it. The message data may be in a buffer or non-existent
4967 * @retval -ENOMSG Returned without waiting.
4968 * @retval -EAGAIN Waiting period timed out.
5087 * @retval -EAGAIN nothing to cleanup
5105 * @retval -ENOMEM if memory couldn't be allocated
5124 * @retval -EIO Returned without waiting; zero data bytes were written.
5125 * @retval -EAGAIN Waiting period timed out; between zero and @a min_xfer
5147 * @retval -EINVAL invalid parameters supplied
5148 * @retval -EIO Returned without waiting; zero data bytes were read.
5149 * @retval -EAGAIN Waiting period timed out; between zero and @a min_xfer
5275 * @retval -EAGAIN if no data could be written before the timeout expired
5276 * @retval -ECANCELED if the write was interrupted by k_pipe_reset(..)
5277 * @retval -EPIPE if the pipe was closed
5293 * @retval -EAGAIN if no data could be read before the timeout expired
5294 * @retval -ECANCELED if the read was interrupted by k_pipe_reset(..)
5295 * @retval -EPIPE if the pipe was closed
5303 * write or read, causing the waiting threads to return with -ECANCELED. Calling k_pipe_read(..) or
5304 * k_pipe_write(..) when the pipe is resetting but not yet reset will return -ECANCELED.
5371 * @brief Statically define and initialize a memory slab in a public (non-static) scope.
5375 * @a slab_align -byte boundary. To ensure that each memory block is similarly
5385 * If such a use-case is desired, use @ref K_MEM_SLAB_DEFINE_STATIC
5406 * @a slab_align -byte boundary. To ensure that each memory block is similarly
5430 * N-byte boundary matching a word boundary, where N is a power of 2
5431 * (i.e. 4 on 32-bit systems, 8, 16, ...).
5441 * @retval -EINVAL invalid data supplied
5465 * @retval -ENOMEM Returned without waiting.
5466 * @retval -EAGAIN Waiting period timed out.
5467 * @retval -EINVAL Invalid data supplied
5495 return slab->info.num_used; in k_mem_slab_num_used_get()
5511 return slab->info.max_used; in k_mem_slab_max_used_get()
5530 return slab->info.num_blocks - slab->info.num_used; in k_mem_slab_num_free_get()
5542 * @retval -EINVAL Any parameter points to NULL
5556 * @retval -EINVAL Memory slab is NULL
5596 * is a multiple of the specified power-of-two alignment value in
5701 /* Hand-calculated minimum heap sizes needed to return a successful
5702 * 1-byte allocation. See details in lib/os/heap.[ch]
5783 * difference is that k_aligned_alloc() accepts any non-zero @p size,
5789 * The aligned_alloc function (p: 347-348)
5843 * smaller than the original, the block will be truncated in place and
5857 /* polling API - PRIVATE */
5860 #define _INIT_OBJ_POLL_EVENT(obj) do { (obj)->poll_event = NULL; } while (false)
5865 /* private - types bit positions */
5888 #define Z_POLL_TYPE_BIT(type) (1U << ((type) - 1U))
5890 /* private - states bit positions */
5916 #define Z_POLL_STATE_BIT(state) (1U << ((state) - 1U))
5919 (32 - (0 \
5926 /* end of polling API - PRIVATE */
5937 /* public - values for k_poll_event.type bitfield */
5946 /* public - polling modes */
5954 /* public - values for k_poll_event.state bitfield */
5964 /* public - poll signal object */
5966 /** PRIVATE - DO NOT TOUCH */
5990 /** PRIVATE - DO NOT TOUCH */
5993 /** PRIVATE - DO NOT TOUCH */
5996 /** optional user-specified tag, opaque, untouched by the API */
5999 /** bitfield of event types (bitwise-ORed K_POLL_TYPE_xxx values) */
6002 /** bitfield of event states (bitwise-ORed K_POLL_STATE_xxx values) */
6008 /** unused bits in 32-bit word */
6011 /** per-type data */
6102 * @retval -EAGAIN Waiting period timed out.
6103 * @retval -EINTR Polling has been interrupted, e.g. with
6106 * words, -EINTR status means that at least one of output events is
6108 * @retval -ENOMEM Thread resource pool insufficient memory (user mode only)
6109 * @retval -EINVAL Bad parameters (user mode only)
6166 * @retval -EAGAIN The polling thread's timeout is in the process of expiring.
6185 * However, in some more constrained systems, such as a single-threaded system,
6201 * Enabling interrupts and entering a low-power mode will be atomic,
6203 * the processor enters a low-power mode.
6205 * After waking up from the low-power mode, the interrupt lockout state will
6324 * @retval -ENOTSUP If the floating point disabling is not implemented.
6325 * -EINVAL If the floating point disabling could not be performed.
6349 * - K_FP_REGS indicates x87 FPU and MMX registers only
6350 * - K_SSE_REGS indicates SSE registers (and also x87 FPU and MMX registers)
6364 * @retval -ENOTSUP If the floating point enabling is not implemented.
6365 * -EINVAL If the floating point enabling could not be performed.
6378 * @return -EINVAL if null pointers, otherwise 0
6387 * @return -EINVAL if null pointers, otherwise 0
6396 * @return -EINVAL if null pointers, otherwise 0
6407 * @return -EINVAL if invalid thread ID, otherwise 0
6418 * @return -EINVAL if invalid thread ID, otherwise 0