21 #include "pedigree/kernel/compiler.h" 23 #include "pedigree/kernel/process/Thread.h" 25 #include "pedigree/kernel/LockGuard.h" 26 #include "pedigree/kernel/Log.h" 27 #include "pedigree/kernel/machine/Machine.h" 28 #include "pedigree/kernel/machine/Timer.h" 29 #include "pedigree/kernel/processor/Processor.h" 30 #include "pedigree/kernel/processor/ProcessorInformation.h" 31 #include "pedigree/kernel/utilities/new" 33 static void guardEventFired(uint8_t *pBuffer)
NORETURN;
36 : m_pEvent(0), m_bTimedOut(false),
56 WARNING(
"TimeoutGuard: TimeoutGuard needs thread support");
91 static void guardEventFired(uint8_t *pBuffer)
96 if (!TimeoutGuard::TimeoutGuardEvent::unserialize(pBuffer, e))
98 FATAL(
"guardEventFired: Event is not a TimeoutGuardEvent!");
101 NOTICE(
"Cancel finished");
105 TimeoutGuard::TimeoutGuardEvent::TimeoutGuardEvent(
108 reinterpret_cast<uintptr_t>(&guardEventFired),
true ,
109 specificNestingLevel),
114 TimeoutGuard::TimeoutGuardEvent::~TimeoutGuardEvent()
120 void *alignedBuffer = ASSUME_ALIGNMENT(pBuffer,
sizeof(
size_t));
121 size_t *pBufferSize_t =
reinterpret_cast<size_t *
>(alignedBuffer);
122 pBufferSize_t[0] = EventNumbers::TimeoutGuard;
123 pBufferSize_t[1] =
reinterpret_cast<size_t>(m_pTarget);
124 return 2 *
sizeof(size_t);
127 bool TimeoutGuard::TimeoutGuardEvent::unserialize(
130 void *alignedBuffer = ASSUME_ALIGNMENT(pBuffer,
sizeof(
size_t));
131 size_t *pBufferSize_t =
reinterpret_cast<size_t *
>(alignedBuffer);
132 if (pBufferSize_t[0] != EventNumbers::TimeoutGuard)
134 event.m_pTarget =
reinterpret_cast<TimeoutGuard *
>(pBufferSize_t[1]);
virtual void removeAlarm(class Event *pEvent)=0
static void restoreState(SchedulerState &state, volatile uintptr_t *pLock=0) NORETURN
TimeoutGuardEvent * m_pEvent
virtual Timer * getTimer()=0
size_t getStateLevel() const
static ProcessorInformation & information()
static bool saveState(SchedulerState &state)
virtual size_t serialize(uint8_t *pBuffer)
TimeoutGuard(size_t timeoutSecs)
virtual void addAlarm(class Event *pEvent, size_t alarmSecs, size_t alarmUsecs=0)=0
Implements the class TimeoutGuard, which cancels any operation after a given amount of time...