Mistake on this page?
Report an issue in GitHub or email us
Modules | Namespaces | Data Structures | Typedefs | Functions | Variables
Rtos

Modules

 EventFlags class
 
 Mail class
 
 MemoryPool class
 
 Mutex class
 
 Queue class
 
 Idle hook function
 
 RtosTimer class
 
 Semaphore class
 
 Thread class
 

Namespaces

 rtos::Kernel
 

Data Structures

struct  rtos::ConditionVariable::Waiter
 
class  rtos::ConditionVariable
 

Typedefs

typedef mbed::ScopedLock< Mutex > rtos::ScopedMutexLock
 
typedef os_mutex_t mbed_rtos_storage_mutex_t
 RTOS primitives storage types for RTX. More...
 
typedef os_semaphore_t mbed_rtos_storage_semaphore_t
 
typedef os_thread_t mbed_rtos_storage_thread_t
 
typedef os_memory_pool_t mbed_rtos_storage_mem_pool_t
 
typedef os_message_queue_t mbed_rtos_storage_msg_queue_t
 
typedef os_event_flags_t mbed_rtos_storage_event_flags_t
 
typedef os_message_t mbed_rtos_storage_message_t
 
typedef os_timer_t mbed_rtos_storage_timer_t
 

Functions

 rtos::ConditionVariable::ConditionVariable (Mutex &mutex)
 
void rtos::ConditionVariable::wait ()
 
bool rtos::ConditionVariable::wait_until (uint64_t millisec)
 
bool rtos::ConditionVariable::wait_for (uint32_t millisec)
 
void rtos::ConditionVariable::notify_one ()
 
void rtos::ConditionVariable::notify_all ()
 
 rtos::ConditionVariable::~ConditionVariable ()
 
static void rtos::ConditionVariable::_add_wait_list (Waiter **wait_list, Waiter *waiter)
 
static void rtos::ConditionVariable::_remove_wait_list (Waiter **wait_list, Waiter *waiter)
 
uint64_t rtos::Kernel::get_ms_count ()
 

Variables

Semaphore rtos::ConditionVariable::Waiter::sem
 
Waiter * rtos::ConditionVariable::Waiter::prev
 
Waiter * rtos::ConditionVariable::Waiter::next
 
bool rtos::ConditionVariable::Waiter::in_list
 
Mutex & rtos::ConditionVariable::_mutex
 
Waiter * rtos::ConditionVariable::_wait_list
 

Detailed Description

Typedef Documentation

typedef os_mutex_t mbed_rtos_storage_mutex_t

RTOS primitives storage types for RTX.

Types defined in this file should be utilized, when the direct RTOS C API usage is required, to provide backing memory for internal RTX data. Allocated object should be wrapped in attribute struct and passed to os*New call, for details see CMSIS-RTOS2 documentation.

Note
This file breaks abstraction layers and uses RTX internal types, but it limits the contamination to single, RTOS implementation specific, header file, therefore limiting scope of possible changes.

Typedef for the mutex lock

Usage:

void foo(Mutex &m) {
ScopedMutexLock lock(m);
// Mutex lock protects code in this block
}

Function Documentation

rtos::ConditionVariable::ConditionVariable ( Mutex mutex)

Create and Initialize a ConditionVariable object

Note
You cannot call this function from ISR context.
uint64_t rtos::Kernel::get_ms_count ( )

Read the current RTOS kernel millisecond tick count. The tick count corresponds to the tick count used by the RTOS for timing purposes. It increments monotonically from 0 at boot, hence effectively never wraps. If the underlying RTOS only provides a 32-bit tick count, this method expands it to 64 bits.

Returns
RTOS kernel current tick count
Note
mbed OS always uses millisecond RTOS ticks, and this could only wrap after half a billion years
You cannot call this function from ISR context.
void rtos::ConditionVariable::notify_all ( )

Notify all waiters on this condition variable that a condition changed.

Note
- The thread calling this function must be the owner of the ConditionVariable's mutex
You cannot call this function from ISR context.
void rtos::ConditionVariable::notify_one ( )

Notify one waiter on this condition variable that a condition changed.

Note
- The thread calling this function must be the owner of the ConditionVariable's mutex
You cannot call this function from ISR context.
void rtos::ConditionVariable::wait ( )

Wait for a notification

Wait until a notification occurs.

Note
- The thread calling this function must be the owner of the ConditionVariable's mutex and it must be locked exactly once
- Spurious notifications can occur so the caller of this API should check to make sure the condition they are waiting on has been met

Example:

mutex.lock();
while (!condition_met) {
cond.wait();
}
function_to_handle_condition();
mutex.unlock();
Note
You cannot call this function from ISR context.
bool rtos::ConditionVariable::wait_for ( uint32_t  millisec)

Wait for a notification or timeout

Parameters
millisectimeout value or osWaitForever in case of no time-out.
Returns
true if a timeout occurred, false otherwise.
Note
- The thread calling this function must be the owner of the ConditionVariable's mutex and it must be locked exactly once
- Spurious notifications can occur so the caller of this API should check to make sure the condition they are waiting on has been met

Example:

mutex.lock();
while (!condition_met) {
cond.wait_for(MAX_SLEEP_TIME);
if (!condition_met) {
do_other_work_while_condition_false();
}
}
if (condition_met) {
function_to_handle_condition();
}
mutex.unlock();
Note
You cannot call this function from ISR context.
bool rtos::ConditionVariable::wait_until ( uint64_t  millisec)

Wait for a notification until specified time

Parameters
millisecabsolute end time referenced to Kernel::get_ms_count()
Returns
true if a timeout occurred, false otherwise.
Note
- The thread calling this function must be the owner of the ConditionVariable's mutex and it must be locked exactly once
- Spurious notifications can occur so the caller of this API should check to make sure the condition they are waiting on has been met

Example:

mutex.lock();
uint64_t end_time = Kernel::get_ms_count() + COND_WAIT_TIMEOUT;
while (!condition_met) {
if (cond.wait_until(end_time)) {
break;
}
}
if (condition_met) {
function_to_handle_condition();
}
mutex.unlock();
Note
You cannot call this function from ISR context.
rtos::ConditionVariable::~ConditionVariable ( )

ConditionVariable destructor

Note
You cannot call this function from ISR context.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.