Lines Matching full:thread
12 The scheduler determines which thread is allowed to execute
13 at any point in time; this thread is known as the **current thread**.
16 opportunity to change the identity of the current thread. These points
19 - transition of a thread from running state to a suspended or waiting
21 - transition of a thread to the :ref:`ready state <thread_states>`, for
23 - return to thread context after processing an interrupt
24 - when a running thread invokes :c:func:`k_yield`
26 A thread **sleeps** when it voluntarily initiates an operation that
29 Whenever the scheduler changes the identity of the current thread,
30 or when execution of the current thread is replaced by an ISR,
31 the kernel first saves the current thread's CPU register values.
32 These register values get restored when the thread later resumes execution.
38 The kernel's scheduler selects the highest priority ready thread
39 to be the current thread. When multiple ready threads of the same priority
42 A thread's relative priority is primarily determined by its static priority.
45 static priority, then the thread with the earlier deadline is considered
49 :c:func:`k_thread_deadline_set` is used to set a thread's deadline.
52 Execution of ISRs takes precedence over thread execution,
53 so the execution of the current thread may be replaced by an ISR
124 Once a cooperative thread becomes the current thread, it remains
125 the current thread until it performs an action that makes it unready.
126 Consequently, if a cooperative thread performs lengthy computations,
134 To overcome such problems, a cooperative thread can voluntarily relinquish
136 A thread can relinquish the CPU in two ways:
138 * Calling :c:func:`k_yield` puts the thread at the back of the scheduler's
141 yielding thread are then allowed to execute before the yielding thread is
143 reschedules the yielding thread without context switching.
145 * Calling :c:func:`k_sleep` makes the thread unready for a specified
148 than that of the sleeping thread will actually be scheduled before
149 the sleeping thread becomes ready once again.
154 Once a preemptive thread becomes the current thread, it remains
155 the current thread until a higher priority thread becomes ready,
156 or until the thread performs an action that makes it unready.
157 Consequently, if a preemptive thread performs lengthy computations,
165 To overcome such problems, a preemptive thread can perform cooperative
177 thread is preemptible and, if so, implicitly invokes :c:func:`k_yield`
178 on behalf of the thread. This gives other ready threads of the same priority
179 the opportunity to execute before the current thread is scheduled again.
180 If no threads of equal priority are ready, the current thread remains
181 the current thread.
184 time slicing, and are never preempted by a thread of equal priority.
191 since it does not measure the amount of time a thread actually gets to
192 execute. However, the algorithm *does* ensure that a thread never executes
198 A preemptible thread that does not wish to be preempted while performing
200 as a cooperative thread by calling :c:func:`k_sched_lock`. This prevents
203 Once the critical operation is complete the preemptible thread must call
206 If a thread calls :c:func:`k_sched_lock` and subsequently performs an
207 action that makes it unready, the scheduler will switch the locking thread out
208 and allow other threads to execute. When the locking thread again
209 becomes the current thread, its non-preemptible status is maintained.
212 Locking out the scheduler is a more efficient way for a preemptible thread
218 Thread Sleeping
221 A thread can call :c:func:`k_sleep` to delay its processing
222 for a specified time period. During the time the thread is sleeping
224 Once the specified delay has elapsed the thread becomes ready
227 A sleeping thread can be woken up prematurely by another thread using
229 to permit the secondary thread to signal the sleeping thread
232 Waking up a thread that is not sleeping is allowed, but has no effect.
239 A thread can call :c:func:`k_busy_wait` to perform a ``busy wait``
241 *without* relinquishing the CPU to another ready thread.
243 A busy wait is typically used instead of thread sleeping
245 context switch from the current thread to another thread and then back again.
263 Although normally reserved for the idle thread, in certain special
264 applications, a thread might want to make the CPU idle.
274 normally an interrupt, wakes up the CPU. In a regular system, the idle thread
276 that another thread takes this duty.
372 Use k_cpu_atomic_idle() when a thread has to do some real work in addition to
375 Use k_cpu_idle() only when a thread is only responsible for idling the CPU,
385 /* thread is only used for CPU idling from this point on */
393 the idle thread takes care of power management, including CPU idling.