summaryrefslogtreecommitdiffstats
path: root/fastos/src/tests
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2022-03-09 09:58:47 +0000
committerHåvard Pettersen <havardpe@oath.com>2022-03-09 09:58:47 +0000
commitf6232099047f24eb952494d555379072144c8aeb (patch)
tree164761f93b7b63dd8804fd6f8b17a9a7220c6a4a /fastos/src/tests
parentb1015bd850fb94157d8c21077578e45628384e02 (diff)
make some variables atomic to make tsan happy
Diffstat (limited to 'fastos/src/tests')
-rw-r--r--fastos/src/tests/job.h2
-rw-r--r--fastos/src/tests/thread_test_base.hpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/fastos/src/tests/job.h b/fastos/src/tests/job.h
index 15356270972..4546cfe1daa 100644
--- a/fastos/src/tests/job.h
+++ b/fastos/src/tests/job.h
@@ -28,7 +28,7 @@ public:
std::mutex *mutex;
std::condition_variable *condition;
FastOS_ThreadInterface *otherThread, *ownThread;
- int result;
+ std::atomic<int> result;
FastOS_ThreadId _threadId;
Job()
diff --git a/fastos/src/tests/thread_test_base.hpp b/fastos/src/tests/thread_test_base.hpp
index 49d37209b6a..12e06395e24 100644
--- a/fastos/src/tests/thread_test_base.hpp
+++ b/fastos/src/tests/thread_test_base.hpp
@@ -5,7 +5,7 @@
#include <chrono>
#include <thread>
-static volatile int64_t number;
+static std::atomic<int64_t> number;
#define INCREASE_NUMBER_AMOUNT 10000
using namespace std::chrono_literals;
@@ -101,7 +101,7 @@ void ThreadTestBase::Run (FastOS_ThreadInterface *thread, void *arg)
int sleepOn = (INCREASE_NUMBER_AMOUNT/2) * 321/10000;
for (int i=0; i<(INCREASE_NUMBER_AMOUNT/2); i++) {
- number = number + 2;
+ number += 2;
if (i == sleepOn)
std::this_thread::sleep_for(1ms);