Kenji Arai / TYBLE16_mbedlized_os5_several_examples_1st

Dependencies:   nRF51_Vdd TextLCD BME280

Embed: (wiki syntax)

« Back to documentation index

Rtos

Data Structures

class  ConditionVariable
 The ConditionVariable class is a synchronization primitive that allows threads to wait until a particular condition occurs. More...

Namespaces

namespace  rtos::Kernel
 

Functions in the Kernel namespace control RTOS kernel information.


Modules

 EventFlags class
 Mail class
 MemoryPool class
 Mutex class
 Queue class
 RTOS hook functions
 Idle hook function
 RtosTimer class
 Semaphore class
 ThisThread namespace
 Thread class

Typedefs

typedef mbed::ScopedLock< Mutex > ScopedMutexLock
 Typedef for the mutex lock.

Functions

void wait ()
 Wait for a notification.
bool wait_until (uint64_t millisec)
 Wait for a notification until the specified time.
bool wait_for (uint32_t millisec)
 Wait for a notification or timeout.
void notify_one ()
 Notify one waiter on this condition variable that a condition changed.
void notify_all ()
 Notify all waiters on this condition variable that a condition changed.
 ~ConditionVariable ()
 ConditionVariable destructor.
void attach_idle_hook (void(*fptr)(void))
 Attach a function to be called by the RTOS idle task.
void attach_thread_terminate_hook (void(*fptr)(osThreadId_t id))
 Attach a function to be called when a thread terminates.

Typedef Documentation

typedef mbed::ScopedLock<Mutex> ScopedMutexLock

Typedef for the mutex lock.

Usage:

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

Definition at line 38 of file Mutex.h.


Function Documentation

void attach_idle_hook ( void(*)(void)  fptr )

Attach a function to be called by the RTOS idle task.

Parameters:
fptrpointer to the function to be called
Note:
You may call this function from ISR context.

Definition at line 66 of file Kernel.cpp.

void attach_thread_terminate_hook ( void(*)(osThreadId_t id)  fptr )

Attach a function to be called when a thread terminates.

Parameters:
fptrpointer to the function to be called
Note:
You may call this function from ISR context.

Definition at line 71 of file Kernel.cpp.

void notify_all (  ) [inherited]

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

This function unblocks all of the threads waiting for the condition variable.

Note:
- The thread calling this function must be the owner of the ConditionVariable's mutex.
- If there are one or more waiters and one or more threads attempting to acquire the condition variable's mutex the order in which the mutex is acquired is undefined.
You cannot call this function from ISR context.

Definition at line 94 of file ConditionVariable.cpp.

void notify_one (  ) [inherited]

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

This function unblocks one of the threads waiting for the condition variable.

Note:
- The thread calling this function must be the owner of the ConditionVariable's mutex.
- The thread that is unblocked on ConditionVariable::notify_one is undefined if there are multiple waiters.
You cannot call this function from ISR context.

Definition at line 85 of file ConditionVariable.cpp.

void wait (  ) [inherited]

Wait for a notification.

Wait causes the current thread to block until the condition variable receives a notification from another thread.

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 the caller is waiting on has been met.
- The current thread releases the lock while inside the wait function and reacquires it upon exiting the function.

Example:

 mutex.lock();

 while (!condition_met) {
     cond.wait();
 }

 function_to_handle_condition();

 mutex.unlock();
Note:
You cannot call this function from ISR context.

Definition at line 41 of file ConditionVariable.cpp.

bool wait_for ( uint32_t  millisec ) [inherited]

Wait for a notification or timeout.

`Wait for` causes the current thread to block until the condition variable receives a notification from another thread, or the timeout specified by the millisec parameter is reached.

Parameters:
millisecTimeout value or osWaitForever in case of no timeout.
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 the caller is waiting on has been met.
- The current thread releases the lock while inside the wait function and reacquire it upon exiting the function.

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.

Definition at line 46 of file ConditionVariable.cpp.

bool wait_until ( uint64_t  millisec ) [inherited]

Wait for a notification until the specified time.

Wait until causes the current thread to block until the condition variable is notified, or a specific time given by millisec parameter is reached.

Parameters:
millisecAbsolute end time referenced to `Kernelget_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 the caller is waiting on has been met.
- The current thread releases the lock while inside the wait function and reacquires it upon exiting the function.

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.

Definition at line 67 of file ConditionVariable.cpp.

~ConditionVariable (  ) [inherited]

ConditionVariable destructor.

Note:
You cannot call this function from ISR context.

Definition at line 148 of file ConditionVariable.cpp.