Browse Source

HAL_PX4: never wait on a semaphore in interrupt context

this shouldn't ever happen, but better to check
master
Andrew Tridgell 8 years ago
parent
commit
a8b12dcf3c
  1. 5
      libraries/AP_HAL_PX4/Semaphores.cpp

5
libraries/AP_HAL_PX4/Semaphores.cpp

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
#include "Semaphores.h"
#include <nuttx/arch.h>
extern const AP_HAL::HAL& hal;
@ -15,6 +16,10 @@ bool Semaphore::give() @@ -15,6 +16,10 @@ bool Semaphore::give()
bool Semaphore::take(uint32_t timeout_ms)
{
if (up_interrupt_context()) {
// don't ever wait on a semaphore in interrupt context
return take_nonblocking();
}
if (timeout_ms == 0) {
return pthread_mutex_lock(&_lock) == 0;
}

Loading…
Cancel
Save