Browse Source
this is needed to allow us to record the location of a blocking semaphore to track down bugs where we have a semaphore deadlockmission-4.1.18
Andrew Tridgell
6 years ago
2 changed files with 56 additions and 0 deletions
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
#include "AP_HAL.h" |
||||
|
||||
extern const AP_HAL::HAL &hal; |
||||
|
||||
/*
|
||||
implement WithSemaphore class for WITH_SEMAPHORE() support |
||||
*/ |
||||
WithSemaphore::WithSemaphore(AP_HAL::Semaphore *mtx, uint32_t line) : |
||||
WithSemaphore(*mtx, line) |
||||
{} |
||||
|
||||
WithSemaphore::WithSemaphore(AP_HAL::Semaphore &mtx, uint32_t line) : |
||||
_mtx(mtx) |
||||
{ |
||||
bool in_main = hal.scheduler->in_main_thread(); |
||||
if (in_main) { |
||||
hal.util->persistent_data.semaphore_line = line; |
||||
} |
||||
_mtx.take_blocking(); |
||||
if (in_main) { |
||||
hal.util->persistent_data.semaphore_line = 0; |
||||
} |
||||
} |
||||
|
||||
WithSemaphore::~WithSemaphore() |
||||
{ |
||||
_mtx.give(); |
||||
} |
Loading…
Reference in new issue