8#include "pedigree/kernel/Log.h"
9#include "pedigree/kernel/process/ExecutionContext.h"
10#include "pedigree/kernel/process/Thread.h"
11#include "pedigree/kernel/processor/Processor.h"
12#include "pedigree/kernel/processor/ProcessorInformation.h"
14ExecutionContextGuard::ExecutionContextGuard(ExecutionContext context)
15 : m_Thread(nullptr), m_StateLevel(0), m_Previous(ExecutionContext::AtomicThread), m_Cleanup() {
24 m_StateLevel = __atomic_load_n(&thread->
m_nStateLevel, __ATOMIC_ACQUIRE);
30 thread->armAtomicStateCleanup(m_Cleanup, abandon,
this);
37ExecutionContextGuard::~ExecutionContextGuard() {
46 thread->disarmAtomicStateCleanup(m_Cleanup);
50void ExecutionContextGuard::abandon(
void* context) {
57void ExecutionContextGuard::restore() {
62 if (m_StateLevel >= MAX_NESTED_EVENTS) {
63 FATAL_NOLOCK(
"Execution-context cleanup recorded an invalid state level");
ExecutionContext enter(ExecutionContext context)
static bool getInterrupts()
static ProcessorInformation & information()
static void setInterrupts(bool bEnable)
ExecutionContextState m_ExecutionContext