mirror of https://github.com/ARMmbed/mbed-os.git
Allow early use of singleton lock
Allow singleton_lock and singleton_unlock to be called before the RTOS has been started by checking for a valid mutex before locking and unlocking it.pull/7794/head
parent
2f8e679183
commit
ec19bf1de4
|
@ -43,6 +43,10 @@ extern osMutexId_t singleton_mutex_id;
|
|||
inline static void singleton_lock(void)
|
||||
{
|
||||
#ifdef MBED_CONF_RTOS_PRESENT
|
||||
if (!singleton_mutex_id) {
|
||||
// RTOS has not booted yet so no mutex is needed
|
||||
return;
|
||||
}
|
||||
osMutexAcquire(singleton_mutex_id, osWaitForever);
|
||||
#endif
|
||||
}
|
||||
|
@ -56,6 +60,10 @@ inline static void singleton_lock(void)
|
|||
inline static void singleton_unlock(void)
|
||||
{
|
||||
#ifdef MBED_CONF_RTOS_PRESENT
|
||||
if (!singleton_mutex_id) {
|
||||
// RTOS has not booted yet so no mutex is needed
|
||||
return;
|
||||
}
|
||||
osMutexRelease(singleton_mutex_id);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue