OS  v1.7.5
Documentation
Loading...
Searching...
No Matches
critical.hpp
1#ifndef QOS_CPP_CRITICAL
2#define QOS_CPP_CRITICAL
3
4#include "include/types.hpp"
5
6namespace qOS {
7
12
30 using int_restorer_t = void (*)( uint32_t );
31
51 using int_disabler_t = uint32_t (*)( void );
52
56 namespace critical {
57
62
74 inline void scope( void ) noexcept {}
75
92 class lock final : private nonCopyable {
93 private:
94 static void enter( void ) noexcept;
95 static void exit( void ) noexcept;
96 static int_disabler_t disable;
97 static int_restorer_t restore;
98 static volatile uint32_t flags;
99 static volatile int nestingLevel;
100 bool entered{ true };
101 friend bool setInterruptsED( const int_restorer_t rFcn, const int_disabler_t dFcn ) noexcept;
102 public:
103 lock() noexcept;
104 ~lock() noexcept;
105 explicit operator bool() noexcept;
106 };
107
118 bool setInterruptsED( const int_restorer_t rFcn, const int_disabler_t dFcn ) noexcept;
119
121 }
122
123}
124
126/*============================================================================*/
127#define scope \
128scope(); \
129for ( critical::lock critical_lock; critical_lock; ) \
130/*============================================================================*/
132
133#endif /*QOS_CPP_CRITICAL*/
friend bool setInterruptsED(const int_restorer_t rFcn, const int_disabler_t dFcn) noexcept
Set the hardware-specific code for global interrupt enable/disable. Setting this allows you to commun...
void scope(void) noexcept
Enables a scoped critical section with minimal syntax overhead.
Definition critical.hpp:74
uint32_t(*)(void) int_disabler_t
Function called by critical::enter() to disable interrupts.
Definition critical.hpp:51
bool setInterruptsED(const int_restorer_t rFcn, const int_disabler_t dFcn) noexcept
Set the hardware-specific code for global interrupt enable/disable. Setting this allows you to commun...
void(*)(uint32_t) int_restorer_t
Function called by critical::exit() to restore interrupts.
Definition critical.hpp:30
OS Critical interfaces.
Definition critical.hpp:56
OS/Kernel interfaces.
Definition bytebuffer.hpp:7