Added barrier pattern, thread yield and updated event API

This commit is contained in:
dario
2024-03-19 14:11:10 +01:00
parent 4ce4653f71
commit 1a8f8c5dff
6 changed files with 141 additions and 8 deletions

View File

@@ -0,0 +1,31 @@
/*
* barrier.hpp
*
* Created on: Mar 16, 2024
* Author: Dario
*/
#ifndef RTOS2_UTILS_STA_PATTERNS_BARRIER_HPP
#define RTOS2_UTILS_STA_PATTERNS_BARRIER_HPP
#include <sta/rtos/mutex.hpp>
#include <sta/rtos/event.hpp>
namespace sta
{
class Barrier {
public:
Barrier(const char* name, uint8_t n_threads);
void wait();
private:
RtosMutex mutex_;
RtosEvent flag_;
const uint8_t n_threads_;
uint8_t n_entered_;
uint8_t n_left_;
};
} // namespace sta
#endif /* RTOS2_UTILS_STA_PATTERNS_BARRIER_HPP_ */