Mistake on this page?
Report an issue in GitHub or email us
Functions
Mbed Thread

Functions

uint64_t get_ms_count (void)
 Generic thread functions. More...
 
void thread_sleep_for (uint32_t millisec)
 Sleep for a specified time period in millisec: More...
 
void thread_sleep_until (uint64_t millisec)
 Sleep until a specified time in millisec The specified time is according to Kernel::get_ms_count(). More...
 

Detailed Description

Function Documentation

uint64_t get_ms_count ( void  )

Generic thread functions.

These are C versions of functions provided in C++ via rtos::Thread and rtos::ThisThreadRead the current RTOS kernel millisecond tick count. The tick count corresponds to the tick count the RTOS uses for timing purposes. It increments monotonically from 0 at boot, so it 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.
In a non-RTOS build, this computes an equivalent time in milliseconds, based on a HAL timer. The time may be referenced as 0 on first call.
You cannot call this function from ISR context.
The equivalent functionality is accessible in C++ via rtos::Kernel::get_ms_count.
void thread_sleep_for ( uint32_t  millisec)

Sleep for a specified time period in millisec:

Parameters
millisectime delay value
Note
You cannot call this function from ISR context.
The equivalent functionality is accessible in C++ via rtos::ThisThread::sleep_for.
void thread_sleep_until ( uint64_t  millisec)

Sleep until a specified time in millisec The specified time is according to Kernel::get_ms_count().

Parameters
millisecabsolute time in millisec
Note
You cannot call this function from ISR context.
if millisec is equal to or lower than the current tick count, this returns immediately.
The equivalent functionality is accessible in C++ via ThisThread::sleep_until.
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.