25 #include "pedigree/kernel/Spinlock.h" 26 #include "pedigree/kernel/compiler.h" 27 #include "pedigree/kernel/process/Event.h" 28 #include "pedigree/kernel/process/SchedulingAlgorithm.h" 29 #include "pedigree/kernel/processor/ProcessorInformation.h" 30 #include "pedigree/kernel/processor/VirtualAddressSpace.h" 31 #include "pedigree/kernel/processor/state_forward.h" 32 #include "pedigree/kernel/processor/types.h" 33 #include "pedigree/kernel/utilities/List.h" 34 #include "pedigree/kernel/utilities/RequestQueue.h" 35 #include "pedigree/kernel/utilities/SharedPointer.h" 36 #include "pedigree/kernel/utilities/new" 42 #define THREAD_TLS_SIZE 0x1000 87 WokenBecauseTerminating,
88 WokenBecauseUnwinding,
93 typedef int (*ThreadStartFunc)(
void *);
114 Process *pParent, ThreadStartFunc pStartFunction,
void *pParam,
115 void *pStack = 0,
bool semiUser =
false,
bool bDontPickCore =
false,
116 bool delayedStart =
false);
125 Thread(
Process *pParent, SyscallState &state,
bool delayedStart =
false);
142 void forceToStartupProcessor();
146 SchedulerState &state();
153 SchedulerState &pushState();
159 void popState(
bool clean =
true);
166 size_t getStateLevel()
const;
169 void allocateStackAtLevel(
size_t stateLevel);
172 void setKernelStack();
178 void pokeState(
size_t stateLevel, SchedulerState &state);
207 void *getKernelStack();
231 return m_bInterrupted;
263 return m_UnwindState;
272 reportWakeup(WokenBecauseUnwinding);
276 void setBlockingThread(
Thread *pT)
278 m_StateLevels[getStateLevel()].m_pBlockingThread = pT;
280 Thread *getBlockingThread(
size_t level = ~0UL)
283 level = getStateLevel();
284 return m_StateLevels[level].m_pBlockingThread;
290 address = m_DebugStateAddress;
296 m_DebugState = state;
297 m_DebugStateAddress = address;
310 bool sendEvent(
Event *pEvent);
315 void inhibitEvent(
size_t eventNumber,
bool bInhibit);
318 void cullEvent(
Event *pEvent);
322 void cullEvent(
size_t eventNumber);
328 Event *getNextEvent();
333 bool hasEvent(
Event *pEvent);
334 bool hasEvent(
size_t eventNumber);
336 void setPriority(
size_t p)
352 void unexpectedExit();
355 uintptr_t getTlsBase();
369 void setTlsBase(uintptr_t base);
373 #ifdef MULTIPROCESSOR 385 #ifdef MULTIPROCESSOR
428 static void threadExited()
NORETURN;
431 bool isInterruptible();
440 void removeWakeupWatcher(
WakeReason *watcher);
450 void setInterruptible(
bool state);
459 void cleanStateLevel(
size_t level);
495 Thread *m_pBlockingThread;
499 size_t m_nStateLevel = 0;
507 void *m_pAllocatedStack =
nullptr;
516 uintptr_t m_DebugStateAddress = 0;
521 size_t m_Priority = DEFAULT_PRIORITY;
524 void *m_pTlsBase =
nullptr;
526 #ifdef MULTIPROCESSOR 567 bool m_bInterrupted =
false;
570 bool m_bTlsBaseOverride =
false;
574 bool m_bRemovingRequests =
false;
577 bool m_bDetached =
false;
580 bool m_bInterruptible =
true;
SharedPointer< ExtensibleBitmap > m_InhibitMask
List< RequestQueue::Request * > m_PendingRequests
void setDebugState(DebugState state, uintptr_t address)
List< Event * > m_EventQueue
void setUnwindState(UnwindType ut)
Spinlock m_ConcurrencyLock
VirtualAddressSpace::Stack * m_pKernelStack
void setErrno(size_t err)
VirtualAddressSpace::Stack * m_pAuxillaryStack
PerProcessorScheduler & operator=(const PerProcessorScheduler &)
Process * getParent() const
void setInterrupted(bool b)
List< WakeReason * > m_WakeWatchers
UnwindType getUnwindState()
DebugState getDebugState(uintptr_t &address)