Thread safety and porting
The thread safety documentation is available in our Reference section.
Considerations when porting
Drivers that operate below the C HAL layer don't need synchronization mechanisms because this is already provided at a higher level. The only exceptions to this are the functions port_read
, port_write
, gpio_read
and gpio_write
, which are expected to use processor-specific set
and clear
registers rather than performing a read-modify-write sequence. For more information, see the example.
HAL C API
The HAL C API is the porting layer of Mbed OS and is not thread safe. Developers should not typically use this API directly, instead using the higher-level drivers and libraries. If you program directly to the HAL C API, it is your responsibility to synchronize operations with an appropriate mechanism, such as a mutex.