fix(px4_platform): fix TSAN issues

This commit is contained in:
Julian Oes
2026-02-18 12:43:47 +13:00
committed by Ramon Roche
parent d0c84d4cc1
commit 578ecc0681
2 changed files with 20 additions and 7 deletions

View File

@@ -40,6 +40,8 @@
#pragma once
#include <px4_platform_common/atomic.h>
namespace px4
{
@@ -48,17 +50,17 @@ class AppState
public:
~AppState() {}
AppState() : _exitRequested(false), _isRunning(false) {}
AppState() {}
bool exitRequested() { return _exitRequested; }
void requestExit() { _exitRequested = true; }
bool exitRequested() { return _exitRequested.load(); }
void requestExit() { _exitRequested.store(true); }
bool isRunning() { return _isRunning; }
void setRunning(bool running) { _isRunning = running; }
bool isRunning() { return _isRunning.load(); }
void setRunning(bool running) { _isRunning.store(running); }
protected:
bool _exitRequested;
bool _isRunning;
px4::atomic_bool _exitRequested{false};
px4::atomic_bool _isRunning{false};
private:
AppState(const AppState &);
const AppState &operator=(const AppState &);

View File

@@ -40,6 +40,7 @@
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/log.h>
#include <px4_platform_common/tasks.h>
#include <px4_platform_common/time.h>
#include <nuttx/board.h>
#include <nuttx/kthread.h>
@@ -91,6 +92,16 @@ int px4_task_delete(int pid)
return task_delete(pid);
}
int px4_task_join(int pid)
{
// Wait for the task to exit by polling whether it still exists
while (kill(pid, 0) == 0) {
px4_usleep(10000);
}
return 0;
}
const char *px4_get_taskname(void)
{
#if CONFIG_TASK_NAME_SIZE > 0 && (defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT))