thread_flags.h¶
Thread Flags API.
-
THREAD_FLAG_MSG_WAITING
¶ Set when a message becomes available.
1
(1u << 15)
This flag is set for a thread if a message becomes available either by being queued in the thread’s message queue or by another thread becoming send-blocked.
It is only reset through thread_flags_wait_*(), not by
msg.h::msg_receive()
.One thread flag event might point to one, many or no messages ready to be received. It is advisable to use the non-blocking
msg.h::msg_try_receive()
in a loop to retrieve the messages. Use e.g., the following pattern when waiting for both thread flags and messages:
-
THREAD_FLAG_TIMEOUT
¶ Set by
xtimer.h::xtimer_set_timeout_flag()
when the timer expires.1
(1u << 14)
See also
-
uint16_t
thread_flags_t
¶ Type definition of thread_flags_t.
-
void
thread_flags_set
(sched.h::thread_t
* thread,thread_flags.h::thread_flags_t
mask)¶ Set thread flags, possibly waking it up.
Parameters
thread: thread to work on mask: additional flags to be set for the current thread, represented as a bitmask
-
thread_flags.h::thread_flags_t
thread_flags_clear
(thread_flags.h::thread_flags_t
mask)¶ Clear current thread’s flags.
Parameters
mask: unset flags for the current thread, represented as a bitmask Return values
- flags that have actually been cleared (mask & thread->flags before clear)
-
thread_flags.h::thread_flags_t
thread_flags_wait_any
(thread_flags.h::thread_flags_t
mask)¶ Wait for any flag in mask to become set (blocking)
If any of the flags in mask are already set, this function will return immediately, otherwise, it will suspend the thread (as THREAD_STATUS_WAIT_ANY) until any of the flags in mask get set.
Both ways, it will clear and return (sched_active_thread-flags & mask).
Parameters
mask: mask of flags to wait for Return values
- flags that caused return/wakeup ((sched_active_thread-flags & mask).
-
thread_flags.h::thread_flags_t
thread_flags_wait_all
(thread_flags.h::thread_flags_t
mask)¶ Wait for all flags in mask to become set (blocking)
If all the flags in mask are already set, this function will return immediately, otherwise, it will suspend the thread (as THREAD_STATUS_WAIT_ALL) until all of the flags in mask have been set.
Both ways, it will clear and return (sched_active_thread-flags & mask).
Parameters
mask: mask of flags to wait for Return values
- mask
-
thread_flags.h::thread_flags_t
thread_flags_wait_one
(thread_flags.h::thread_flags_t
mask)¶ Wait for any flags in mask to become set (blocking), one at a time.
This function is like
thread_flags.h::thread_flags_wait_any()
, but will only clear and return one flag at a time, least significant set bit first.Parameters
mask: mask of flags to wait for Return values
- flag that triggered the return / wait
-
int
thread_flags_wake
(sched.h::thread_t
* thread)¶ Possibly Wake up thread waiting for flags.
Wakes up a thread if it is thread flag blocked and its condition is met. Has to be called with interrupts disabled. Does not trigger yield.