|
The Pedigree Project 0.1
|
#include <Thread.h>
Collaboration diagram for Thread:Classes | |
| struct | AlternateSignalStack |
| struct | DeferredProcessExit |
| struct | JoinDiscardContext |
| class | SecurityState |
| class | StackDiscardScope |
| struct | StateLevel |
| class | TemporarySignalMask |
| class | UserReturnFrameScope |
| struct | WaitDebugInfo |
Public Types | |
| enum | UserReturnWorkFlag : size_t { UserReturnExternalWork = 1 , UserReturnEventsDeferred = 1 << 1 , UserReturnSignalFrames = 1 << 3 , UserReturnDeferredException = 1 << 4 , UserReturnOriginalSyscall = 1 << 5 } |
| enum | Status { Created , Ready , Running , Sleeping , Zombie , AwaitingJoin } |
| enum | DebugState { None , SemWait , CondWait , Joining , FutexWait , EventWait , ProcessWait , CallbackDrain } |
| enum | InterruptionReason { NotInterrupted , InterruptedByTimeout , InterruptedBySignal } |
| enum | UnwindType { Continue = 0 , Exit , TerminateThread } |
| typedef int(* | ThreadStartFunc) (void *) |
| using | SecurityStateRef = SharedPointer< SecurityState > |
Public Member Functions | |
| UserReturnFrame * | currentUserReturnFrame () const |
| bool | tryRequireSignalFrames () |
| void | clearSignalFrameRequirement () |
| void | setUserReturnSignalParked (bool parked) |
| bool | canSkipUserReturnWork () |
| bool | clearUserReturnWorkIfIdle () |
| bool | userReturnWorkPending () const |
| bool | requiresSignalFrames () const |
| Thread (Process *pParent, ThreadStartFunc pStartFunction, void *pParam, void *pStack=0, bool semiUser=false, bool bDontPickCore=false, bool delayedStart=false, const ThreadPlacement *placement=nullptr) | |
| Thread (Process *pParent) | |
| Thread (Process *pParent, SyscallState &state, bool delayedStart=false, const ThreadPlacement *placement=nullptr) | |
| void | snapshotPlacement (ThreadPlacement &placement) |
| bool | hasSecurityState () const |
| SecurityStateRef | securityState () |
| void | setSecurityState (const SecurityStateRef &state) |
| void | snapshotPlacementLocked (ThreadPlacement &placement) const |
| AffinityResult | requestAffinity (const CpuAffinityMask &mask, uint64_t &generation) |
| AffinityResult | waitAffinity (uint64_t generation) |
| AffinityResult | completeAffinityAtSafePoint (bool *waited=nullptr) |
| bool | affinityWorkPending () const |
| virtual | ~Thread () |
| void | shutdown () |
| void | notifySubsystemExit () |
| void | forceToStartupProcessor () |
| SchedulerState & | state () |
| SchedulerState * | pushState () |
| void | popState (bool clean=true) |
| void | abandonCurrentState (bool clean=false) |
| void | abandonAllStates () |
| VirtualAddressSpace::Stack * | getStateUserStack () |
| void | setStateUserStack (VirtualAddressSpace::Stack *st) |
| void | discardUserStackMetadataForExec () |
| void | adoptInitialUserStackForExec (VirtualAddressSpace::Stack *stack) |
| size_t | getStateLevel () const |
| void * | getSyscallDispatchContext () const |
| void | setSyscallDispatchContext (void *context) |
| void | allocateStackAtLevel (size_t stateLevel) |
| void | setKernelStack () |
| void | pokeState (size_t stateLevel, SchedulerState &state) |
| Process * | getParent () const |
| void | setClearChildTid (uintptr_t address) |
| uintptr_t | takeClearChildTid () |
| void | setRobustList (uintptr_t address, size_t ownerId) |
| uintptr_t | getRobustList () const |
| uintptr_t | takeRobustList (size_t &ownerId) |
| void | recordTime (CpuTimeMode mode) |
| void | trackTime (CpuTimeMode mode) |
| void | transitionTime (CpuTimeMode from, CpuTimeMode to, bool interruptsAlreadyDisabled=false) |
| ALWAYS_INLINE void | transitionTimeAtInterruptReturn (CpuTimeMode from, CpuTimeMode to) |
| CpuTimeMode | currentTimeAccountingMode () const |
| void | accountTimerTick (Time::Timestamp delta, bool kernelMode) |
| Time::Timestamp | getUserTime () const |
| Time::Timestamp | getKernelTime () const |
| void | setParent (Process *p) |
| ExecutionPersonality & | executionPersonality () |
| Status | getStatus () const |
| bool | start () |
| bool | startDetached () |
| int | getExitCode () |
| void * | getKernelStack () |
| void * | getKernelStackBase (size_t *size) const |
| size_t | getId () |
| size_t | getUserspaceTaskId (const UserspacePidNamespace *space=nullptr) const |
| size_t | getTaskId () const |
| size_t | getErrno () |
| void | setErrno (size_t err) |
| bool | wasInterrupted () |
| void | clearInterruption () |
| InterruptionReason | getInterruptionReason () |
| void | setInterruptionReason (InterruptionReason reason) |
| void | markTimeoutInterruptedWait () |
| void | markSignalInterruptedWait () |
| UnwindType | getUnwindState () |
| void | setUnwindState (UnwindType ut) |
| void | deferProcessExit (int code) |
| void | deferSignalExit (int signal) |
| DeferredProcessExit | takeDeferredProcessExit () |
| bool | deferSubsystemException (size_t type, uintptr_t faultAddress, uintptr_t errorCode) |
| bool | hasDeferredSubsystemException () const |
| bool | takeDeferredSubsystemException (size_t &type, uintptr_t &faultAddress, uintptr_t &errorCode) |
| bool | isTerminationDeferred () const |
| DebugState | getDebugState (uintptr_t &address) |
| void | setDebugState (DebugState state, uintptr_t address) |
| bool | getWaitDebugInfo (WaitDebugInfo &info) |
| Spinlock & | getLock () |
| bool | sendEvent (Event *pEvent) |
| void | waitForEvent (WaitQueue::StackDiscardCleanup onStackDiscard=nullptr, void *stackDiscardContext=nullptr) |
| bool | waitForEventOrSignalInterruption (WaitQueue::StackDiscardCleanup onStackDiscard=nullptr, void *stackDiscardContext=nullptr) |
| void | inhibitEvent (size_t eventNumber, bool bInhibit) |
| uint64_t | getSignalMask () |
| void | setSignalMask (uint64_t mask) |
| uint64_t | getSignalMaskForReturnFrame () |
| void | commitSignalHandlerMask (uint64_t mask) |
| void | restoreDeferredSignalMask (size_t stateLevel) |
| const SyscallState * | getOriginalSyscallState () const |
| void | setOriginalSyscallState (const SyscallState *state) |
| void | setCurrentSignalDelivery (size_t signalNumber, size_t continuationEpoch) |
| bool | getCurrentSignalDelivery (size_t &signalNumber, size_t &continuationEpoch) |
| void | prepareSignalStateForExec () |
| bool | hasTemporarySignalWaitInterruption () |
| bool | hasActiveTemporarySignalMask () |
| bool | retainTemporarySignalWaitInterruptionOrClear () |
| AlternateSignalStack & | getAlternateSignalStack () |
| void | cullEvent (Event *pEvent) |
| void | cullEvent (size_t eventNumber) |
| void | cullSignalEvent (size_t signalNumber) |
| bool | transferProcessSignalsTo (Thread &target) |
| bool | replaceSignalEvent (size_t signalNumber, Event *replacement, int processDirected=-1, uint64_t rebindGeneration=0) |
| bool | hasSignalEvent (size_t signalNumber, int processDirected=-1) |
| bool | acceptingEvents () |
| uint64_t | pendingSignalMask (bool processOnly=false) |
| uint64_t | pendingSignalOrder (size_t signal, bool processOnly=false) |
| Event::Delivery | reservePendingSignal (uint64_t mask, bool processOnly=false, uint64_t expectedSequence=~uint64_t(0)) |
| bool | restorePendingSignal (Event::Delivery &delivery) |
| void | cullSignalSource (const void *source) |
| void | setSynchronousSignalMask (uint64_t mask) |
| uint64_t | getSynchronousSignalMask () |
| bool | hasEvents () |
| bool | hasEvent (Event *pEvent) |
| bool | hasEvent (size_t eventNumber) |
| void | setPriority (size_t p) |
| size_t | getPriority () |
| void | unexpectedExit () |
| uintptr_t | getTlsBase () |
| void | resetTlsBase () |
| void | setTlsBase (uintptr_t base) |
| uintptr_t | getUserGsBase () const |
| void | setUserGsBase (uintptr_t base) |
| void | saveUserGsBase () |
| size_t | getCpuId () |
| void | setCpuId (size_t id) |
| bool | join () |
| bool | joinForCompletion () |
| bool | detach () |
| bool | detached () const |
| bool | eventsDeferred () const |
| ExecutionContext | executionContext () const |
| class PerProcessorScheduler * | getScheduler () const |
| const String & | getName () const |
| void | setName (const String &name) |
| template<size_t N> | |
| void | setName (const char(&name)[N]) |
Static Public Member Functions | |
| static void | threadExited () NORETURN |
Protected Member Functions | |
| void | setScheduler (class PerProcessorScheduler *pScheduler) |
| void | deferEvents () |
| void | resumeEvents () |
| void | deferTermination () |
| void | resumeTermination () |
| void | markUserReturnWorkFlag (UserReturnWorkFlag flag) |
| void | clearUserReturnWorkFlag (UserReturnWorkFlag flag) |
| void | markUserReturnWorkPending () |
| void | registerDeferredScope (DeferredScopeRecord &record, bool termination, bool events) |
| void | armStateCleanup (DeferredScopeRecord &record, DeferredScopeRecord::Cleanup cleanup, void *context) |
| void | unregisterDeferredScope (DeferredScopeRecord &record) |
| void | disarmStateCleanup (DeferredScopeRecord &record) |
| void | unregisterTerminationDeferral (DeferredScopeRecord &record) |
| void | moveTerminationDeferral (DeferredScopeRecord &from, DeferredScopeRecord &to) |
| void | retireDeferredScopes (bool allStateLevels, size_t stateLevel=0) |
| size_t | stateCleanupCheckpoint () |
| void | retireDeferredScopesAfter (size_t checkpoint) |
| void | retireDeferredScopesMatching (bool allStateLevels, size_t stateLevel, bool newerThanCheckpoint, size_t checkpoint) |
| void | armAtomicStateCleanup (AtomicStateCleanupRecord &record, AtomicStateCleanupRecord::Cleanup cleanup, void *context) |
| void | disarmAtomicStateCleanup (AtomicStateCleanupRecord &record) |
Private Types | |
| enum class | EventSelection { AnyDeliverable , WithoutExactUserReturn , KernelDeliverable , StoppedProcessKernel } |
Private Member Functions | |
| void | publishDeferredScope (DeferredScopeRecord &record, bool termination, bool events, DeferredScopeRecord::Cleanup cleanup, void *context) |
| void | unpublishDeferredScope (DeferredScopeRecord &record, bool deferrals) |
| void | registerFreshTerminationDeferral (DeferredScopeRecord &record, DeferredScopeRecord::Cleanup cleanup=nullptr, void *context=nullptr) |
| Thread (const Thread &) | |
| Thread & | operator= (const Thread &) |
| void | publishTimeAccounting (CpuTimeMode mode, Time::Timestamp elapsed) |
| void | initialisePlacement (const ThreadPlacement *placement) |
| void | publishReadyNotification () |
| void | cleanStateLevel (size_t level) |
| size_t | beginTemporarySignalMask (uint64_t signalMask) |
| bool | finishTemporarySignalMask (size_t stateLevel, bool deferForUserReturn=true) |
| bool | waitForEventInternal (bool stopOnSignalInterruption, WaitQueue::StackDiscardCleanup onStackDiscard, void *stackDiscardContext) |
| bool | eventNeedsUserReturnFrameUnlocked (Event *event) const |
| bool | eventIsDeliverableUnlocked (Event *event, EventSelection selection=EventSelection::AnyDeliverable) |
| bool | hasEventsUnlocked (EventSelection selection=EventSelection::AnyDeliverable) |
| bool | hasDeliverableEventsUnlocked (EventSelection selection=EventSelection::AnyDeliverable) |
| void | markDeferredUserReturnSignalInterruption () |
| void | wakeForDeliverableEvents () |
| MUST_USE_RESULT Event::Delivery | getNextEvent (EventSelection selection=EventSelection::AnyDeliverable) |
| void | setStatus (Status s) |
| void | setStatusUnlocked (Status s) |
| bool | markReapable () |
| bool | joinInternal (bool completion) |
| bool | beginExternalLease () |
| void | endExternalLease () |
| void | closeExternalLeaseAdmission () |
| void | closeExternalLeaseAdmissionAndDrain () |
| bool | interruptWaitUnlocked (WaitQueue::WakeReason reason, PerProcessorScheduler *&readyScheduler) |
| bool | hasActiveWaitUnlocked () const |
| bool | hasActiveWaitAtAnyLevel () const |
| bool | activeWaitPendingUnlocked () const |
| void | unlinkWaitsForStackDiscard () |
| void | markTerminalWaitCancelledBeforeBlockUnlocked (size_t level) |
| bool | consumeTerminalWaitCancelledBeforeBlockUnlocked () |
| void | clearTerminalWaitCancelledBeforeBlockUnlocked (size_t level) |
Static Private Member Functions | |
| static void | discardJoin (void *context) |
Friends | |
| class | PerProcessorScheduler |
| class | Scheduler |
| class | PageFaultHandler |
| class | Process |
| class | WaitQueue |
| class | Uninterruptible |
| class | TerminationDeferral |
| class | SyscallManager |
| class | IrqHandlerRegistry |
| class | TimerHandlerRegistry |
| class | HostedInterruptManager |
| class | RoundRobin |
| class | ExecutionContextGuard |
| class | RequestQueueCallbackScope |
| class | SchedulerTimerDispatchCleanup |
An abstraction of a thread of execution.
The thread maintains not just one execution context (SchedulerState) but a stack of them, along with a stack of masks for inhibiting event dispatch.
This enables event dispatch at any time without affecting the previous state, as well as changing the event mask from nested event handlers without affecting the state of any other running handler.
| typedef int(* Thread::ThreadStartFunc) (void *) |
| enum Thread::DebugState |
| enum Thread::Status |
| enum Thread::UnwindType |
| Thread::Thread | ( | Process * | pParent, |
| ThreadStartFunc | pStartFunction, | ||
| void * | pParam, | ||
| void * | pStack = 0, |
||
| bool | semiUser = false, |
||
| bool | bDontPickCore = false, |
||
| bool | delayedStart = false, |
||
| const ThreadPlacement * | placement = nullptr |
||
| ) |
Creates a new Thread belonging to the given Process. It shares the Process' * virtual address space.
The constructor registers itself with the Scheduler and parent process - this * does not need to be done manually.
If kernelMode is true, and pStack is NULL, no stack space is assigned.
| pParent | The parent process. Can never be NULL. |
| kernelMode | Is the thread going to be operating in kernel space only? * |
| pStartFunction | The function to be run when the thread starts. * |
| pParam | A parameter to give the startFunction. * |
| pStack | (Optional) A (user mode) stack to give the thread - applicable for user mode threads * only. * |
| semiUser | (Optional) Whether to start the thread as if it was a user mode thread, but begin in kernel mode (to do setup and jump to usermode manually). * |
| delayedStart | (Optional) Start the thread in a halted state. |
Definition at line 224 of file Thread.cc.
References Spinlock::acquire(), Process::addThread(), Scheduler::addThread(), ProcessorThreadAllocator::addThread(), allocateStackAtLevel(), getParent(), getScheduler(), getUnwindState(), ProcessorBase::information(), Scheduler::instance(), m_Id, Thread::StateLevel::m_InhibitMask, m_Lock, m_nStateLevel, m_pAllocatedStack, Thread::StateLevel::m_pAuxillaryStack, Thread::StateLevel::m_pKernelStack, m_pParent, Thread::StateLevel::m_SignalMask, m_Status, and TerminateThread.
| Thread::Thread | ( | Process * | pParent | ) |
Alternative constructor - this should be used only by initialiseMultitasking() to define the first kernel thread.
Definition at line 304 of file Thread.cc.
References Process::addThread(), Scheduler::addThread(), Scheduler::instance(), m_Id, and m_pParent.
| Thread::Thread | ( | Process * | pParent, |
| SyscallState & | state, | ||
| bool | delayedStart = false, |
||
| const ThreadPlacement * | placement = nullptr |
||
| ) |
Constructor for when forking a process. Assumes pParent has already been set up with a clone of the current address space and sets up the new thread to return to the caller in that address space.
Definition at line 322 of file Thread.cc.
References Spinlock::acquire(), Process::addThread(), ProcessorThreadAllocator::addThread(), allocateStackAtLevel(), getParent(), getUnwindState(), ProcessorBase::information(), NMFaultHandler::inheritCurrentThreadFpuState(), m_AlternateSignalStack, m_bTlsBaseOverride, m_Id, Thread::StateLevel::m_InhibitMask, m_Lock, m_nStateLevel, m_pAllocatedStack, m_pParent, m_pTlsBase, Thread::StateLevel::m_SignalMask, m_Status, state(), and TerminateThread.
|
virtual |
Destroys the Thread.
The destructor unregisters itself with the Scheduler and parent process - this does not need to be done manually.
Definition at line 475 of file Thread.cc.
References cleanStateLevel(), Dec, EMIT_IF, PhysicalMemoryManager::freePage(), Process::getAddressSpace(), VirtualAddressSpace::getDynamicStart(), VirtualAddressSpace::getMapping(), Scheduler::instance(), NMFaultHandler::instance(), PhysicalMemoryManager::instance(), VirtualAddressSpace::isMapped(), m_ActiveSyscalls, m_bExternalLeaseAdmissionClosed, m_bExternalLeaseReleaseInProgress, m_bShutdown, m_bTlsBaseOverride, m_EventDeferralDepth, m_ExternalLeaseLock, m_nExternalLeases, m_pDeferredScopes, m_pParent, m_pTlsBase, m_TerminationDeferralDepth, Process::removeThread(), Scheduler::removeThread(), shutdown(), and VirtualAddressSpace::unmap().
|
private |
Copy-constructor
| void Thread::abandonAllStates | ( | ) |
Abandons every nested event state before a no-return user transition.
Definition at line 965 of file Thread.cc.
References abandonCurrentState(), and getStateLevel().
Referenced by X64SyscallManager::syscall().
Here is the caller graph for this function:| void Thread::abandonCurrentState | ( | bool | clean = false | ) |
Abandons the current event state without running stack destructors.
Definition at line 956 of file Thread.cc.
References m_nStateLevel, and popState().
Referenced by abandonAllStates(), PerProcessorScheduler::eventHandlerReturned(), and X64SyscallManager::syscall().
Here is the caller graph for this function:| void Thread::accountTimerTick | ( | Time::Timestamp | delta, |
| bool | kernelMode | ||
| ) |
Charges a scheduler tick using the saved interrupt mode, with IRQs masked.
Definition at line 422 of file Thread.cc.
References m_pParent, and publishTimeAccounting().
Referenced by PerProcessorScheduler::timer().
Here is the caller graph for this function:| void Thread::adoptInitialUserStackForExec | ( | VirtualAddressSpace::Stack * | stack | ) |
Gives the replacement image's initial stack to this Thread's base state.
Definition at line 1018 of file Thread.cc.
References m_Lock.
Referenced by PosixSubsystem::invoke().
Here is the caller graph for this function:| void Thread::allocateStackAtLevel | ( | size_t | stateLevel | ) |
Allocates a new stack for a specific nesting level, if required
Definition at line 1054 of file Thread.cc.
References VirtualAddressSpace::allocateStack(), VirtualAddressSpace::getKernelAddressSpace(), Thread::StateLevel::m_pKernelStack, Thread::StateLevel::m_State, and state().
Referenced by pushState(), Thread(), and Thread().
Here is the caller graph for this function:
|
protected |
|
protected |
|
private |
Admits a Process::ThreadLease while this object remains discoverable.
Definition at line 2852 of file Thread.cc.
References m_bExternalLeaseAdmissionClosed, m_ExternalLeaseLock, and m_nExternalLeases.
Referenced by Process::acquireProcessSignalThread(), Process::acquireThread(), Process::acquireThread(), Process::acquireThreadById(), Process::beginTermination(), completeAffinityAtSafePoint(), requestAffinity(), and Scheduler::sampleLoadAverage().
Here is the caller graph for this function:
|
private |
| bool Thread::canSkipUserReturnWork | ( | ) |
Definition at line 78 of file Thread-user-return.cc.
|
private |
Cleans up the given state level.
Definition at line 3535 of file Thread.cc.
References VirtualAddressSpace::freeStack(), Process::getAddressSpace(), VirtualAddressSpace::getKernelAddressSpace(), Thread::StateLevel::m_bOwnsAlternateSignalStack, Thread::StateLevel::m_bTerminalWaitCancelledBeforeBlock, Thread::StateLevel::m_DispatchedSignalNumber, Thread::StateLevel::m_ExecutionContext, Thread::StateLevel::m_InhibitMask, Thread::StateLevel::m_pAuxillaryStack, m_pDeferredScopes, Thread::StateLevel::m_pKernelStack, m_pParent, Thread::StateLevel::m_pRequestQueueCallback, Thread::StateLevel::m_SavedSignalMask, SharedPointer< T >::reset(), and restoreDeferredSignalMask().
Referenced by popState(), and ~Thread().
Here is the caller graph for this function:| void Thread::clearSignalFrameRequirement | ( | ) |
Definition at line 58 of file Thread-user-return.cc.
|
private |
|
inlineprotected |
| bool Thread::clearUserReturnWorkIfIdle | ( | ) |
Definition at line 85 of file Thread-user-return.cc.
|
private |
Prevents any further Process::ThreadLease acquisition.
Definition at line 2946 of file Thread.cc.
References m_bExternalLeaseAdmissionClosed, and m_ExternalLeaseLock.
|
private |
Closes external admission and drains every previously admitted lease.
Definition at line 2951 of file Thread.cc.
References m_bExternalLeaseAdmissionClosed, m_bExternalLeaseReleaseInProgress, m_ExternalLeaseLock, m_ExternalLeaseWaiters, and m_nExternalLeases.
Referenced by detach(), joinInternal(), startDetached(), and Process::~Process().
Here is the caller graph for this function:| void Thread::commitSignalHandlerMask | ( | uint64_t | mask | ) |
Transfers a deferred mask restoration into a successfully published frame.
Definition at line 1997 of file Thread.cc.
References m_Lock, m_nStateLevel, Thread::StateLevel::m_SignalMask, and state().
| AffinityResult Thread::completeAffinityAtSafePoint | ( | bool * | waited = nullptr | ) |
Current-thread gate for an audited continuation without CPU-local state. Applies the latest acknowledged mask without changing it; returns with interrupts disabled, including Terminal. Ordinary waits are not gates.
Definition at line 157 of file Thread-affinity.cc.
References Process::beginExternalLease(), beginExternalLease(), Continue, Process::endExternalLease(), endExternalLease(), getScheduler(), getUnwindState(), ProcessorBase::information(), m_bShutdown, m_Lock, m_pParent, and ProcessorBase::setInterrupts().
Referenced by X64InterruptManager::returnFromInterrupt(), and X64SyscallManager::syscall().
Here is the caller graph for this function:
|
private |
| void Thread::cullEvent | ( | Event * | pEvent | ) |
Walks the event queue, removing the event pEvent , if found.
Definition at line 2172 of file Thread.cc.
References List< T, nodePoolSize >::begin(), Event::deregisterThread(), List< T, nodePoolSize >::end(), List< T, nodePoolSize >::erase(), m_EventQueue, and m_Lock.
| void Thread::cullEvent | ( | size_t | eventNumber | ) |
Walks the event queue, removing the event with number eventNumber , if found.
Definition at line 2194 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), List< T, nodePoolSize >::erase(), m_EventQueue, m_Lock, and Vector< T >::pushBack().
| void Thread::cullSignalEvent | ( | size_t | signalNumber | ) |
Removes only signal events matching signalNumber from the queue.
Definition at line 2216 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), List< T, nodePoolSize >::erase(), m_EventQueue, m_Lock, and Vector< T >::pushBack().
Referenced by PosixSubsystem::queueSignalDelivery(), and PosixSubsystem::setSignalHandler().
Here is the caller graph for this function:| CpuTimeMode Thread::currentTimeAccountingMode | ( | ) | const |
Current accounting owner; never used to classify interrupt origin.
Definition at line 471 of file Thread.cc.
References m_CurrentTimeAccountingMode.
Referenced by InterruptTimeAccounting::finishUserReturn(), PerProcessorScheduler::serviceProcessStopAtUserReturn(), and HostedSyscallManager::syscall().
Here is the caller graph for this function:| UserReturnFrame * Thread::currentUserReturnFrame | ( | ) | const |
Definition at line 42 of file Thread-user-return.cc.
| void Thread::deferProcessExit | ( | int | code | ) |
Defers process exit, including its status, to a safe thread boundary.
Definition at line 3605 of file Thread.cc.
References Exit, m_DeferredProcessExitRequest, and setUnwindState().
| void Thread::deferSignalExit | ( | int | signal | ) |
Defers signal-caused process exit to a safe thread boundary.
Definition at line 3612 of file Thread.cc.
References Exit, m_DeferredProcessExitRequest, and setUnwindState().
Referenced by PosixSubsystem::invoke(), and PosixSubsystem::threadException().
Here is the caller graph for this function:| bool Thread::deferSubsystemException | ( | size_t | type, |
| uintptr_t | faultAddress, | ||
| uintptr_t | errorCode | ||
| ) |
Publishes a synchronous userspace exception without taking locks or allocating from its raw interrupt frame.
Definition at line 3627 of file Thread.cc.
References m_DeferredSubsystemExceptionState.
Referenced by HostedInterruptManager::interrupt(), X64InterruptManager::interrupt(), and PageFaultHandler::interrupt().
Here is the caller graph for this function:| bool Thread::detach | ( | ) |
Marks the thread as detached.
A detached thread cannot be joined and will be automatically cleaned up when the thread entry point returns, or the thread is otherwise terminated. A thread cannot be detached if another thread is already join()ing it.
Definition at line 2987 of file Thread.cc.
References Process::beginThreadJoin(), closeExternalLeaseAdmissionAndDrain(), Process::endThreadJoin(), m_bDetached, m_bDetachedRetirementClaimed, m_bJoinClaimed, m_bProcessExitOwned, m_bReapable, m_JoinWaiters, Process::m_Lock, and m_pParent.
|
inline |
|
protected |
|
protected |
|
staticprivate |
Releases a join claim if an exceptional stack discard cannot return.
Definition at line 2969 of file Thread.cc.
References Process::endThreadJoin(), m_bJoinClaimed, and m_JoinWaiters.
Referenced by joinInternal().
Here is the caller graph for this function:| void Thread::discardUserStackMetadataForExec | ( | ) |
Drops descriptors for user stacks whose mappings were removed by exec. The discarded image has already been unmapped, so this must not ask the address space to free those virtual ranges again.
Definition at line 981 of file Thread.cc.
References ProcessorBase::information(), and m_Lock.
Referenced by PosixSubsystem::invoke().
Here is the caller graph for this function:
|
private |
Releases a successful external lease admission.
Definition at line 2862 of file Thread.cc.
References m_bDetached, m_bDetachedRetirementClaimed, m_bExternalLeaseAdmissionClosed, m_bExternalLeaseReleaseInProgress, m_bProcessExitOwned, m_bReapable, m_ExternalLeaseLock, m_ExternalLeaseWaiters, m_JoinWaiters, Process::m_Lock, m_nExternalLeases, and m_pParent.
Referenced by completeAffinityAtSafePoint(), Process::releaseThreadLease(), and requestAffinity().
Here is the caller graph for this function:
|
private |
|
private |
Checks one event against masks and process state while m_Lock is held.
Definition at line 64 of file Thread-user-return.cc.
Referenced by markDeferredUserReturnSignalInterruption().
Here is the caller graph for this function:| bool Thread::eventsDeferred | ( | ) | const |
Gets whether event delivery is currently deferred.
Definition at line 3159 of file Thread.cc.
References m_EventDeferralDepth.
Referenced by PerProcessorScheduler::checkEventState(), and publishTimeAccounting().
Here is the caller graph for this function:| ExecutionContext Thread::executionContext | ( | ) | const |
Returns this Thread's explicit logical execution context.
Definition at line 836 of file Thread.cc.
References Thread::StateLevel::m_ExecutionContext, and m_nStateLevel.
Referenced by ProcessorBase::executionContext().
Here is the caller graph for this function:
|
inline |
|
private |
|
inline |
|
inline |
| bool Thread::getCurrentSignalDelivery | ( | size_t & | signalNumber, |
| size_t & | continuationEpoch | ||
| ) |
Retrieves trusted metadata for the signal dispatched at the current level.
Definition at line 2028 of file Thread.cc.
References Thread::StateLevel::m_DispatchedSignalNumber, m_Lock, m_nStateLevel, and state().
|
inline |
Returns the thread's debug state.
Definition at line 574 of file Thread.h.
Referenced by Rtc::drainRemoteAlarmDispatch(), and IrqHandlerRegistry::unregisterHandler().
Here is the caller graph for this function:
|
inline |
Returns the last error that occurred (errno).
Definition at line 477 of file Thread.h.
Referenced by HostedSyscallManager::syscall(), and X64SyscallManager::syscall().
Here is the caller graph for this function:
|
inline |
|
inline |
Returns the Thread's ID.
Definition at line 465 of file Thread.h.
Referenced by Process::beginTermination(), PerProcessorScheduler::checkEventState(), X64InterruptManager::interrupt(), Process::publishTerminationReapable(), PosixSubsystem::sendSignal(), Process::terminatingThreadReapable(), PosixSubsystem::threadException(), and Process::~Process().
Here is the caller graph for this function:
|
inline |
| void * Thread::getKernelStack | ( | ) |
Retrieves a pointer to the top of the Thread's kernel stack.
Definition at line 1070 of file Thread.cc.
References m_nStateLevel, and Thread::StateLevel::m_pKernelStack.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), PerProcessorScheduler::checkEventState(), and PerProcessorScheduler::initialise().
Here is the caller graph for this function:| void * Thread::getKernelStackBase | ( | size_t * | size | ) | const |
Retrieves a pointer to the bottom of the Thread's kernel stack, and its size.
Definition at line 1080 of file Thread.cc.
References m_nStateLevel, Thread::StateLevel::m_pAuxillaryStack, and Thread::StateLevel::m_pKernelStack.
|
inline |
Returns the thread's scheduler lock.
Definition at line 613 of file Thread.h.
Referenced by PerProcessorScheduler::addThread(), and PerProcessorScheduler::addThread().
Here is the caller graph for this function:
|
private |
Scheduler-only dequeue that retains the Event delivery registration.
Definition at line 2466 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), List< T, nodePoolSize >::erase(), m_EventDeferralDepth, m_EventQueue, and m_Lock.
Referenced by PerProcessorScheduler::checkEventState().
Here is the caller graph for this function:
|
inline |
|
inline |
Retrieves a pointer to this Thread's parent process.
Definition at line 340 of file Thread.h.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), SlamAllocator::allocate(), Process::beginTermination(), PerProcessorScheduler::checkEventState(), X64PreparedPageRemap::commit(), PerProcessorScheduler::commitUserReturnTerminalState(), X64VirtualAddressSpace::detachEmptyTables(), PosixSubsystem::exit(), PerProcessorScheduler::initialise(), HostedInterruptManager::interrupt(), X64InterruptManager::interrupt(), PageFaultHandler::interrupt(), X64VirtualAddressSpace::invalidateMapping(), PosixSubsystem::invoke(), PosixSubsystem::kill(), Process::prepareThreadExit(), File::publishEvent(), PosixSubsystem::queueSignalDelivery(), Process::releaseVforkAddressSpace(), PosixSubsystem::resetSignalHandlersForExec(), PosixSubsystem::resolveUserPageFault(), Scheduler::sampleLoadAverage(), PosixSubsystem::sendSignal(), PerProcessorScheduler::serviceDeferredSubsystemException(), PerProcessorScheduler::serviceProcessStopAtUserReturn(), Process::suspendInternal(), X64SyscallManager::syscall(), Thread(), Thread(), PosixSubsystem::threadException(), threadExited(), and PosixSubsystem::threadExiting().
Here is the caller graph for this function:
|
inline |
Gets the per-processor scheduler for this Thread.
Definition at line 929 of file Thread.h.
Referenced by PerProcessorScheduler::checkEventState(), completeAffinityAtSafePoint(), Scheduler::recordCpuTime(), requestAffinity(), PosixSubsystem::sendSignal(), Process::suspendInternal(), X64SyscallManager::syscall(), and Thread().
Here is the caller graph for this function:| uint64_t Thread::getSignalMask | ( | ) |
Retrieves the POSIX signal mask for the current event nesting level.
Definition at line 1981 of file Thread.cc.
References m_Lock, m_nStateLevel, and Thread::StateLevel::m_SignalMask.
Referenced by PosixSubsystem::queueSignalDelivery(), and SignalEvent::serialize().
Here is the caller graph for this function:| uint64_t Thread::getSignalMaskForReturnFrame | ( | ) |
Saves the pre-wait mask when delivery completes an interrupted masked wait.
Definition at line 1991 of file Thread.cc.
References m_Lock, m_nStateLevel, and state().
|
inline |
Returns the state nesting level.
Definition at line 316 of file Thread.h.
Referenced by abandonAllStates(), PerProcessorScheduler::checkEventState(), prepareSignalStateForExec(), and threadExited().
Here is the caller graph for this function:| VirtualAddressSpace::Stack * Thread::getStateUserStack | ( | ) |
|
inline |
Retrieves our current status.
Definition at line 433 of file Thread.h.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), Scheduler::sampleLoadAverage(), and Process::~Process().
Here is the caller graph for this function:| uintptr_t Thread::getTlsBase | ( | ) |
Gets the TLS base address for this thread.
Definition at line 2644 of file Thread.cc.
References PhysicalMemoryManager::allocatePage(), Dec, Process::getAddressSpace(), VirtualAddressSpace::getDynamicStart(), Process::getId(), Hex, PhysicalMemoryManager::instance(), m_bTlsBaseOverride, m_Id, m_pParent, m_pTlsBase, VirtualAddressSpace::map(), VirtualAddressSpace::RuntimeMapping, and VirtualAddressSpace::Write.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), PerProcessorScheduler::initialise(), resetTlsBase(), setTlsBase(), and PosixSubsystem::threadException().
Here is the caller graph for this function:
|
inline |
Returns nonzero if the thread has been asked to unwind quickly.
This happens if this thread (or a thread blocking on this thread) is scheduled for deletion. The intended behaviour is that the stack is unwound as quickly as possible with all semaphores and buffers deleted to a point where
(a) no threads can possibly be blocking on this or (b) The thread has no more locks taken and is ready to be destroyed, at which point it should call the subsys exit() function.
Whether to adopt option A or B depends on whether this thread or not has been asked to terminate, given by the return value.
Definition at line 535 of file Thread.h.
Referenced by Process::acquireProcessSignalThread(), PerProcessorScheduler::commitUserReturnTerminalState(), completeAffinityAtSafePoint(), PosixSubsystem::invoke(), Process::prepareThreadExit(), PosixSubsystem::queueSignalDelivery(), requestAffinity(), PerProcessorScheduler::serviceProcessStopAtUserReturn(), PerProcessorScheduler::serviceUserReturnWork(), start(), startDetached(), HostedSyscallManager::syscall(), X64SyscallManager::syscall(), Thread(), Thread(), and threadExited().
Here is the caller graph for this function:| size_t Thread::getUserspaceTaskId | ( | const UserspacePidNamespace * | space = nullptr | ) | const |
Linux task IDs share the PID namespace; internal slots remain local.
Definition at line 3743 of file Thread.cc.
References Process::getId(), Process::getUserspaceId(), and m_pParent.
|
inline |
Gets CPU time charged specifically to this Thread.
Definition at line 412 of file Thread.h.
Referenced by Process::removeThread(), Process::totalTime(), and Process::~Process().
Here is the caller graph for this function:| bool Thread::getWaitDebugInfo | ( | WaitDebugInfo & | info | ) |
Takes a best-effort snapshot of the active wait for the debugger.
Definition at line 3163 of file Thread.cc.
References m_nStateLevel, and Thread::StateLevel::m_Waiter.
| bool Thread::hasActiveTemporarySignalMask | ( | ) |
True while the current state owns a temporary signal mask.
Definition at line 2151 of file Thread.cc.
References m_Lock, and m_nStateLevel.
|
inline |
|
private |
| bool Thread::hasEvent | ( | Event * | pEvent | ) |
Determines if the given event is currently in the event queue.
Definition at line 2618 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), m_EventQueue, and m_Lock.
|
private |
Checks for an event that can run while m_Lock is already held.
Definition at line 2587 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), and m_EventQueue.
| bool Thread::hasSignalEvent | ( | size_t | signalNumber, |
| int | processDirected = -1 |
||
| ) |
Filters process/thread provenance when specified; -1 matches either.
Definition at line 2345 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), m_EventQueue, and m_Lock.
Referenced by PosixSubsystem::queueSignalDelivery().
Here is the caller graph for this function:| bool Thread::hasTemporarySignalWaitInterruption | ( | ) |
True only while the current state owns an interrupted temporary signal wait.
Definition at line 2144 of file Thread.cc.
References m_Lock, m_nStateLevel, and state().
| void Thread::inhibitEvent | ( | size_t | eventNumber, |
| bool | bInhibit | ||
| ) |
Sets the given event number as inhibited.
| bInhibit | True if the event is to be inhibited, false if the event is to be allowed. |
Definition at line 1973 of file Thread.cc.
References ExtensibleBitmap::clear(), Thread::StateLevel::m_InhibitMask, m_Lock, m_nStateLevel, and ExtensibleBitmap::set().
|
private |
Definition at line 54 of file Thread-affinity.cc.
|
private |
Interrupts the active wait at the current event nesting level.
Definition at line 3657 of file Thread.cc.
References m_nStateLevel, m_Status, and Thread::StateLevel::m_Waiter.
Referenced by sendEvent(), setUnwindState(), and wakeForDeliverableEvents().
Here is the caller graph for this function:
|
inline |
True while an explicit terminal-teardown deferral is active.
Definition at line 569 of file Thread.h.
Referenced by PerProcessorScheduler::commitUserReturnTerminalState(), and PerProcessorScheduler::serviceUserReturnWork().
Here is the caller graph for this function:| bool Thread::join | ( | ) |
Blocks until the Thread returns.
After join() returns successfully, the thread object is NOT valid.
Definition at line 2746 of file Thread.cc.
References joinInternal().
Referenced by pocketknife::attachTo().
Here is the caller graph for this function:| bool Thread::joinForCompletion | ( | ) |
Joins as a lifetime barrier which terminal teardown cannot abandon.
Use only for owned worker destruction/cleanup. Ordinary callers should use join(), which remains interruptible.
Definition at line 2750 of file Thread.cc.
References joinInternal().
Referenced by pocketknife::attachToForCompletion(), OwnedThread::join(), and InputManager::shutdown().
Here is the caller graph for this function:
|
private |
Implements ordinary and completion-safe exclusive joins.
Definition at line 2755 of file Thread.cc.
References Process::beginThreadJoin(), closeExternalLeaseAdmissionAndDrain(), discardJoin(), Process::endThreadJoin(), ProcessorBase::information(), m_bDetached, m_bJoinClaimed, m_bProcessExitOwned, m_bReapable, m_JoinWaiters, Process::m_Lock, m_pParent, and WaitQueue::Guard::waitForCompletion().
Referenced by join(), and joinForCompletion().
Here is the caller graph for this function:
|
private |
Marks a caught signal deferred until an exact user-return boundary.
Definition at line 2551 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), eventNeedsUserReturnFrameUnlocked(), Event::isSignalEvent(), Thread::StateLevel::m_bDispatchingWaitEvent, m_EventQueue, m_EventWaiters, m_Lock, and m_nStateLevel.
Referenced by PerProcessorScheduler::checkEventState().
Here is the caller graph for this function:
|
private |
Completes exit after the scheduler has switched away from our stack. Returns true when a concurrent detach made immediate deletion safe.
Definition at line 3721 of file Thread.cc.
References m_bDetached, m_bDetachedRetirementClaimed, m_bExternalLeaseAdmissionClosed, m_bExternalLeaseReleaseInProgress, m_bProcessExitOwned, m_bReapable, m_ExternalLeaseLock, m_JoinWaiters, and m_nExternalLeases.
| void Thread::markSignalInterruptedWait | ( | ) |
Marks a signal only when its delivery actually interrupted a wait.
Definition at line 3131 of file Thread.cc.
References Thread::StateLevel::m_bDispatchingWaitEvent, m_EventWaiters, m_Lock, and m_nStateLevel.
Referenced by SignalEvent::serialize().
Here is the caller graph for this function:
|
private |
| void Thread::markTimeoutInterruptedWait | ( | ) |
Marks a timeout in the context interrupted by the current event.
Definition at line 3126 of file Thread.cc.
References m_nStateLevel.
|
inlineprotected |
|
protected |
| void Thread::notifySubsystemExit | ( | ) |
Runs subsystem exit hooks once, while the lifecycle owner can still block and before the final scheduler handoff.
Definition at line 547 of file Thread.cc.
References VirtualAddressSpace::freeStack(), Process::getAddressSpace(), m_bSubsystemExitNotified, m_pParent, and Process::threadExiting().
Referenced by PosixSubsystem::exit(), and shutdown().
Here is the caller graph for this function:| uint64_t Thread::pendingSignalMask | ( | bool | processOnly = false | ) |
| uint64_t Thread::pendingSignalOrder | ( | size_t | signal, |
| bool | processOnly = false |
||
| ) |
| void Thread::pokeState | ( | size_t | stateLevel, |
| SchedulerState & | state | ||
| ) |
Overwrites the state at the given nesting level.
| stateLevel | The nesting level to edit. |
| state | The state to copy. |
Definition at line 1107 of file Thread.cc.
References Thread::StateLevel::m_State, and state().
| void Thread::popState | ( | bool | clean = true | ) |
Decreases the state nesting level by one, popping both the state stack and the inhibit mask stack. If clean == true, the stacks and other resources will also be cleaned up. Pass clean = false if losing the stack would be dangerous in a particular context.
Definition at line 913 of file Thread.cc.
References cleanStateLevel(), ProcessorBase::getInterrupts(), m_AlternateSignalStack, Thread::StateLevel::m_bOwnsAlternateSignalStack, m_Lock, m_nStateLevel, m_pDeferredScopes, ProcessorBase::setInterrupts(), and setKernelStack().
Referenced by abandonCurrentState(), and PerProcessorScheduler::checkEventState().
Here is the caller graph for this function:| void Thread::prepareSignalStateForExec | ( | ) |
Carries the effective signal state into a replacement process image.
Definition at line 2040 of file Thread.cc.
References getStateLevel(), m_AlternateSignalStack, Thread::StateLevel::m_bDispatchingWaitEvent, Thread::StateLevel::m_bOwnsAlternateSignalStack, Thread::StateLevel::m_DispatchedSignalNumber, m_Lock, m_nStateLevel, Thread::StateLevel::m_SavedSignalMask, Thread::StateLevel::m_SignalMask, and state().
|
inlineprivate |
|
private |
Definition at line 245 of file Thread-affinity.cc.
|
private |
Adds one elapsed interval and requests any interested process timer report.
Definition at line 435 of file Thread.cc.
References eventsDeferred(), Scheduler::instance(), m_pParent, m_UserTime, and Scheduler::recordCpuTime().
Referenced by accountTimerTick(), trackTime(), and transitionTime().
Here is the caller graph for this function:| SchedulerState * Thread::pushState | ( | ) |
Increases the state nesting level by one - pushes a new state to the top of the state stack. This also pushes the event mask and per-context syscall state.
Definition at line 841 of file Thread.cc.
References allocateStackAtLevel(), ProcessorBase::getInterrupts(), Thread::StateLevel::m_bDispatchingWaitEvent, Thread::StateLevel::m_bOwnsAlternateSignalStack, Thread::StateLevel::m_DispatchedSignalNumber, Thread::StateLevel::m_Errno, Thread::StateLevel::m_ExecutionContext, Thread::StateLevel::m_InhibitMask, m_Lock, m_nStateLevel, m_pDeferredScopes, Thread::StateLevel::m_pRequestQueueCallback, Thread::StateLevel::m_SavedSignalMask, Thread::StateLevel::m_SignalMask, Thread::StateLevel::m_State, ProcessorBase::setInterrupts(), and setKernelStack().
Referenced by PerProcessorScheduler::checkEventState().
Here is the caller graph for this function:| void Thread::recordTime | ( | CpuTimeMode | mode | ) |
Records this Thread's monotonic entry baseline for one CPU-time mode.
Definition at line 384 of file Thread.cc.
References m_CurrentTimeAccountingMode, m_TimeAccounting, and ThreadTimeAccounting::recordAtInterruptDisabled().
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), and PerProcessorScheduler::initialise().
Here is the caller graph for this function:
|
protected |
|
private |
| bool Thread::replaceSignalEvent | ( | size_t | signalNumber, |
| Event * | replacement, | ||
| int | processDirected = -1, |
||
| uint64_t | rebindGeneration = 0 |
||
| ) |
Replaces one queued signal delivery without making it transiently deliverable. On success the Thread owns replacement; otherwise the caller retains ownership.
Definition at line 2270 of file Thread.cc.
References List< T, nodePoolSize >::begin(), Event::beginSend(), Event::completeDelivery(), Event::deregisterThread(), List< T, nodePoolSize >::end(), Event::getNumber(), Event::isSignalEvent(), m_bShutdown, m_EventQueue, m_EventSenderDrainWaiters, m_EventSendersInFlight, m_EventWaiters, m_Lock, m_Status, Event::registerThread(), SignalEvent::setContinuationEpoch(), and SignalEvent::setSignalOrigin().
| AffinityResult Thread::requestAffinity | ( | const CpuAffinityMask & | mask, |
| uint64_t & | generation | ||
| ) |
Success admits the returned generation; Busy names the existing one.
Definition at line 72 of file Thread-affinity.cc.
References Process::beginExternalLease(), beginExternalLease(), Continue, Process::endExternalLease(), endExternalLease(), getScheduler(), getUnwindState(), m_bShutdown, m_Lock, m_pParent, and m_Status.
| Event::Delivery Thread::reservePendingSignal | ( | uint64_t | mask, |
| bool | processOnly = false, |
||
| uint64_t | expectedSequence = ~uint64_t(0) |
||
| ) |
| void Thread::resetTlsBase | ( | ) |
Resets the TLS base address for this thread and re-maps it. Note: doesn't free the memory - only call after a call to something like revertToKernelAddressSpace!
Definition at line 2691 of file Thread.cc.
References getTlsBase(), m_bTlsBaseOverride, m_pTlsBase, and ProcessorBase::setTlsBase().
Referenced by PosixSubsystem::invoke().
Here is the caller graph for this function:| void Thread::restoreDeferredSignalMask | ( | size_t | stateLevel | ) |
Restores an interrupted wait's mask when no signal frame took ownership.
Definition at line 2007 of file Thread.cc.
References m_Lock, Thread::StateLevel::m_SignalMask, and state().
Referenced by cleanStateLevel().
Here is the caller graph for this function:| bool Thread::restorePendingSignal | ( | Event::Delivery & | delivery | ) |
| bool Thread::retainTemporarySignalWaitInterruptionOrClear | ( | ) |
Retains an armed temporary-wait signal, or atomically clears stale interruption state.
Definition at line 2156 of file Thread.cc.
References Spinlock::acquire(), ProcessorBase::getInterrupts(), m_Lock, m_nStateLevel, Spinlock::release(), ProcessorBase::setInterrupts(), and state().
|
protected |
|
protected |
|
protected |
| Thread::SecurityStateRef Thread::securityState | ( | ) |
| bool Thread::sendEvent | ( | Event * | pEvent | ) |
Sends the asynchronous event pEvent to this thread.
If the thread ID is greater than or equal to EVENT_TID_MAX, the event will be ignored.
The event is not cloned. On success the thread owns a deletable event; on failure ownership remains with the caller.
Definition at line 1115 of file Thread.cc.
References List< T, nodePoolSize >::begin(), Event::beginSend(), Event::completeDelivery(), Event::deregisterThread(), List< T, nodePoolSize >::end(), Event::getNumber(), interruptWaitUnlocked(), Event::isSignalEvent(), m_bShutdown, m_EventQueue, m_EventSenderDrainWaiters, m_EventSendersInFlight, m_EventWaiters, m_Lock, m_Status, PerProcessorScheduler::publishReadyFromWait(), List< T, nodePoolSize >::pushBack(), and Event::registerThread().
Referenced by PerProcessorScheduler::checkEventState(), File::dataChanged(), RingBuffer< T, preallocatedSize >::monitor(), BufferMonitors::notify(), Rtc::processElapsedTime(), HostedTimer::processTimerBatch(), PosixSubsystem::queueSignalDelivery(), and transferProcessSignalsTo().
Here is the caller graph for this function:| void Thread::setClearChildTid | ( | uintptr_t | address | ) |
Replaces the userspace address cleared when this thread exits.
Definition at line 653 of file Thread.cc.
References m_bShutdown, m_ClearChildTid, and m_Lock.
Referenced by PosixSubsystem::invoke().
Here is the caller graph for this function:
|
inline |
Sets this thread's CPU ID
Definition at line 870 of file Thread.h.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), and PerProcessorScheduler::initialise().
Here is the caller graph for this function:| void Thread::setCurrentSignalDelivery | ( | size_t | signalNumber, |
| size_t | continuationEpoch | ||
| ) |
Records trusted metadata for the signal dispatched at the current level.
Definition at line 2021 of file Thread.cc.
References Thread::StateLevel::m_DispatchedSignalNumber, m_Lock, m_nStateLevel, and state().
Referenced by SignalEvent::serialize().
Here is the caller graph for this function:
|
inline |
Sets the thread's debug state.
Definition at line 593 of file Thread.h.
Referenced by Rtc::drainRemoteAlarmDispatch(), and IrqHandlerRegistry::unregisterHandler().
Here is the caller graph for this function:
|
inline |
Sets the last error - errno.
Definition at line 482 of file Thread.h.
Referenced by HostedSyscallManager::syscall(), and X64SyscallManager::syscall().
Here is the caller graph for this function:
|
inline |
| void Thread::setKernelStack | ( | ) |
Sets the new kernel stack for the current state level in the TSS
Definition at line 1099 of file Thread.cc.
References ProcessorBase::information(), m_nStateLevel, and Thread::StateLevel::m_pKernelStack.
Referenced by popState(), and pushState().
Here is the caller graph for this function:
|
inline |
|
inline |
| void Thread::setRobustList | ( | uintptr_t | address, |
| size_t | ownerId | ||
| ) |
|
protected |
Sets the scheduler for the Thread.
Definition at line 3531 of file Thread.cc.
Referenced by Scheduler::addThread(), PerProcessorScheduler::addThread(), and PerProcessorScheduler::addThread().
Here is the caller graph for this function:| void Thread::setSecurityState | ( | const SecurityStateRef & | state | ) |
| void Thread::setSignalMask | ( | uint64_t | mask | ) |
Sets the POSIX signal mask for the current event nesting level.
Definition at line 1986 of file Thread.cc.
References m_Lock, m_nStateLevel, and Thread::StateLevel::m_SignalMask.
Referenced by SignalEvent::serialize().
Here is the caller graph for this function:| void Thread::setStateUserStack | ( | VirtualAddressSpace::Stack * | st | ) |
|
private |
Scheduler-only status transition primitive.
Definition at line 719 of file Thread.cc.
References m_Lock.
Referenced by PerProcessorScheduler::initialise(), and shutdown().
Here is the caller graph for this function:
|
private |
|
inline |
| void Thread::setTlsBase | ( | uintptr_t | base | ) |
Set the TLS base for this thread. Once set, it must be cleaned up by the caller when the thread terminates, which makes this primarily useful for userspace TLS segments. This does not access the supplied memory.
Definition at line 2722 of file Thread.cc.
References getTlsBase(), ProcessorBase::information(), m_bTlsBaseOverride, m_pTlsBase, and ProcessorBase::setTlsBase().
| void Thread::setUnwindState | ( | UnwindType | ut | ) |
Sets the above unwind state.
Definition at line 3580 of file Thread.cc.
References Continue, Scheduler::instance(), interruptWaitUnlocked(), m_Lock, m_Status, PerProcessorScheduler::publishReadyFromWait(), and TerminateThread.
Referenced by deferProcessExit(), deferSignalExit(), PosixSubsystem::exit(), and startDetached().
Here is the caller graph for this function:| void Thread::setUserReturnSignalParked | ( | bool | parked | ) |
Definition at line 69 of file Thread-user-return.cc.
| void Thread::shutdown | ( | ) |
Performs termination steps on the thread, while the thread is still able to reschedule. Required as ~Thread() is called in a context where the thread has been removed from the scheduler, and triggering a reschedule may add the thread back to the ready queue by accident.
Definition at line 570 of file Thread.cc.
References Event::completeDelivery(), List< T, nodePoolSize >::count(), m_bExitStarted, m_bShutdown, m_EventQueue, m_EventSenderDrainWaiters, m_EventSendersInFlight, m_JoinWaiters, m_Lock, m_pParent, notifySubsystemExit(), List< T, nodePoolSize >::popFront(), setStatus(), Process::transferExecProcessSignals(), and unlinkWaitsForStackDiscard().
Referenced by ~Thread().
Here is the caller graph for this function:| void Thread::snapshotPlacement | ( | ThreadPlacement & | placement | ) |
Definition at line 63 of file Thread-affinity.cc.
| void Thread::snapshotPlacementLocked | ( | ThreadPlacement & | placement | ) | const |
The allocator already holds the new Thread's construction lock.
Definition at line 68 of file Thread-affinity.cc.
| bool Thread::start | ( | ) |
Starts a thread constructed with delayedStart=true.
This is deliberately distinct from waking a blocked thread: only its WaitQueue may perform that transition.
Definition at line 751 of file Thread.cc.
References getUnwindState(), Scheduler::instance(), m_bStartRequested, m_Lock, m_Status, and TerminateThread.
Referenced by startDetached().
Here is the caller graph for this function:| bool Thread::startDetached | ( | ) |
Publishes a delayed worker as detached while retaining its final-use claim. A terminal cancellation which already owns the thread is accepted as successful publication. Success may destroy this Thread before the call returns, so callers must not access it afterward.
Definition at line 769 of file Thread.cc.
References Process::beginThreadJoin(), closeExternalLeaseAdmissionAndDrain(), Process::endThreadJoin(), getUnwindState(), m_bDetached, m_bDetachedRetirementClaimed, m_bJoinClaimed, m_bProcessExitOwned, m_bReapable, m_JoinWaiters, Process::m_Lock, m_pParent, setUnwindState(), start(), and TerminateThread.
Referenced by PosixSubsystem::invoke().
Here is the caller graph for this function:| SchedulerState & Thread::state | ( | ) |
Returns a reference to the Thread's saved context. This function is intended only for use by the Scheduler.
Definition at line 832 of file Thread.cc.
References m_nStateLevel, and Thread::StateLevel::m_State.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), allocateStackAtLevel(), commitSignalHandlerMask(), PerProcessorScheduler::eventHandlerReturned(), getCurrentSignalDelivery(), getSignalMaskForReturnFrame(), hasTemporarySignalWaitInterruption(), NMFaultHandler::inheritCurrentThreadFpuState(), NMFaultHandler::interrupt(), PosixSubsystem::invoke(), markTerminalWaitCancelledBeforeBlockUnlocked(), pokeState(), prepareSignalStateForExec(), NMFaultHandler::restoreCurrentThreadFpuState(), restoreDeferredSignalMask(), retainTemporarySignalWaitInterruptionOrClear(), NMFaultHandler::saveCurrentThreadFpuState(), setCurrentSignalDelivery(), and Thread().
Here is the caller graph for this function:
|
inline |
| Thread::DeferredProcessExit Thread::takeDeferredProcessExit | ( | ) |
Claims the status and cause attached to a deferred process exit.
Definition at line 3618 of file Thread.cc.
References m_DeferredProcessExitRequest.
Referenced by PerProcessorScheduler::commitUserReturnTerminalState(), HostedSyscallManager::syscall(), X64SyscallManager::syscall(), and threadExited().
Here is the caller graph for this function:| bool Thread::takeDeferredSubsystemException | ( | size_t & | type, |
| uintptr_t & | faultAddress, | ||
| uintptr_t & | errorCode | ||
| ) |
Claims a synchronous exception at an IRQ-enabled return boundary.
Definition at line 3643 of file Thread.cc.
References m_DeferredSubsystemExceptionState.
Referenced by PerProcessorScheduler::serviceDeferredSubsystemException().
Here is the caller graph for this function:
|
static |
Sets the exit code of the Thread and sets the state to Zombie, if it is being waited on; if it is not being waited on the Thread is destroyed.
Definition at line 1030 of file Thread.cc.
References Exit, Subsystem::exit(), getParent(), getStateLevel(), getUnwindState(), ProcessorBase::information(), and takeDeferredProcessExit().
| void Thread::trackTime | ( | CpuTimeMode | mode | ) |
Publishes elapsed time from this Thread into its Process aggregate.
Definition at line 392 of file Thread.cc.
References ThreadTimeAccounting::elapsedAtInterruptDisabled(), m_TimeAccounting, and publishTimeAccounting().
Referenced by PerProcessorScheduler::addThread(), and PerProcessorScheduler::addThread().
Here is the caller graph for this function:| bool Thread::transferProcessSignalsTo | ( | Thread & | target | ) |
Moves queued process signals, retaining rejected deliveries on this thread. The caller pins both threads and serialises process signal publication.
Definition at line 2238 of file Thread.cc.
References List< T, nodePoolSize >::begin(), Event::completeDelivery(), List< T, nodePoolSize >::end(), List< T, nodePoolSize >::erase(), m_EventQueue, m_Lock, List< T, nodePoolSize >::pushFront(), and sendEvent().
Referenced by PosixSubsystem::prepareThreadsForExec(), and PosixSubsystem::preserveProcessSignalsForThreadExit().
Here is the caller graph for this function:| void Thread::transitionTime | ( | CpuTimeMode | from, |
| CpuTimeMode | to, | ||
| bool | interruptsAlreadyDisabled = false |
||
| ) |
Accounts one CPU-mode transition from a single monotonic sample.
Definition at line 405 of file Thread.cc.
References ThreadTimeAccounting::elapsedAtInterruptDisabled(), m_CurrentTimeAccountingMode, m_TimeAccounting, publishTimeAccounting(), and ThreadTimeAccounting::recordAtInterruptDisabled().
Referenced by PerProcessorScheduler::checkEventState(), TimeTracker::finish(), TimeTracker::finishInKernel(), and X64SyscallManager::syscall().
Here is the caller graph for this function:
|
inline |
Accounts a transition while the architecture already has IRQ delivery physically masked.
Definition at line 373 of file Thread.h.
Referenced by InterruptTimeAccounting::finishUserReturn(), and X64SyscallManager::syscall().
Here is the caller graph for this function:| bool Thread::tryRequireSignalFrames | ( | ) |
Definition at line 49 of file Thread-user-return.cc.
| void Thread::unexpectedExit | ( | ) |
An unexpected exit has occurred, perform cleanup
Definition at line 2642 of file Thread.cc.
Referenced by PosixSubsystem::exit().
Here is the caller graph for this function:
|
private |
Unpublishes every waiter before exceptional stack cleanup can run.
Definition at line 640 of file Thread.cc.
References Thread::StateLevel::m_Waiter.
Referenced by PerProcessorScheduler::abandonCurrentThreadStack(), and shutdown().
Here is the caller graph for this function:
|
inlineprivate |
|
protected |
|
protected |
| AffinityResult Thread::waitAffinity | ( | uint64_t | generation | ) |
Wait without retaining caller locks; the caller must retain this Thread.
Definition at line 136 of file Thread-affinity.cc.
References m_Lock.
| void Thread::waitForEvent | ( | WaitQueue::StackDiscardCleanup | onStackDiscard = nullptr, |
| void * | stackDiscardContext = nullptr |
||
| ) |
|
private |
| bool Thread::waitForEventOrSignalInterruption | ( | WaitQueue::StackDiscardCleanup | onStackDiscard = nullptr, |
| void * | stackDiscardContext = nullptr |
||
| ) |
|
private |
Rechecks queued events after the parent process becomes runnable.
Definition at line 2601 of file Thread.cc.
References interruptWaitUnlocked(), m_bShutdown, m_EventWaiters, m_Lock, m_Status, and PerProcessorScheduler::publishReadyFromWait().
Referenced by Process::resume().
Here is the caller graph for this function:
|
inline |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
|
private |
Alternate signal stack configuration is per-thread.
Definition at line 1302 of file Thread.h.
Referenced by PerProcessorScheduler::checkEventState(), popState(), prepareSignalStateForExec(), and Thread().
|
private |
Whether this thread has been detached or not.
Definition at line 1355 of file Thread.h.
Referenced by detach(), endExternalLease(), joinInternal(), markReapable(), and startDetached().
|
private |
Exactly one path owns detached Thread destruction.
Definition at line 1361 of file Thread.h.
Referenced by detach(), endExternalLease(), markReapable(), and startDetached().
|
private |
Thread shutdown has started, but its stack may still be in use.
Definition at line 1367 of file Thread.h.
Referenced by Process::beginTermination(), Process::prepareThreadExit(), and shutdown().
|
private |
Whether no new external Thread leases may be acquired.
Definition at line 1277 of file Thread.h.
Referenced by beginExternalLease(), closeExternalLeaseAdmission(), closeExternalLeaseAdmissionAndDrain(), endExternalLease(), markReapable(), and ~Thread().
|
private |
The final releaser is still deciding detached retirement.
A zero lease count alone is not enough for scheduler-side deletion: the releasing call still has to inspect this Thread after decrementing.
Definition at line 1285 of file Thread.h.
Referenced by closeExternalLeaseAdmissionAndDrain(), endExternalLease(), markReapable(), and ~Thread().
|
private |
Whether join() has been claimed by another thread.
Definition at line 1358 of file Thread.h.
Referenced by detach(), discardJoin(), joinInternal(), startDetached(), and Process::~Process().
|
private |
Process destruction owns this Thread object once it is off-stack.
Definition at line 1373 of file Thread.h.
Referenced by Process::addThread(), Process::beginTermination(), detach(), endExternalLease(), joinInternal(), markReapable(), and startDetached().
|
private |
This thread is included in its Process' exit rendezvous.
Definition at line 1376 of file Thread.h.
Referenced by Process::addThread(), Process::beginTermination(), and Process::terminatingThreadReapable().
|
private |
The scheduler has switched off this thread's stack.
Definition at line 1370 of file Thread.h.
Referenced by Process::beginTermination(), detach(), endExternalLease(), joinInternal(), markReapable(), Process::prepareThreadExit(), Process::publishTerminationReapable(), startDetached(), and Process::~Process().
|
private |
Whether shutdown() has completed its one-way transition.
Definition at line 1339 of file Thread.h.
Referenced by Process::acquireProcessSignalThread(), completeAffinityAtSafePoint(), replaceSignalEvent(), requestAffinity(), sendEvent(), setClearChildTid(), shutdown(), wakeForDeliverableEvents(), and ~Thread().
|
private |
|
private |
Process teardown can notify before shutdown retires the final thread.
Definition at line 1342 of file Thread.h.
Referenced by notifySubsystemExit().
|
private |
One-way syscall exit intent, protected by the parent Process lock.
Definition at line 1364 of file Thread.h.
Referenced by Process::prepareThreadExit().
|
private |
Whether or not userspace has overridden its TLS base.
Definition at line 1336 of file Thread.h.
Referenced by getTlsBase(), resetTlsBase(), setTlsBase(), Thread(), and ~Thread().
|
private |
Userspace TID word cleared by the subsystem during exit publication.
Definition at line 1345 of file Thread.h.
Referenced by setClearChildTid().
|
private |
Mode owning time since the most recent accounting baseline.
Definition at line 1199 of file Thread.h.
Referenced by currentTimeAccountingMode(), recordTime(), and transitionTime().
|
private |
|
private |
|
private |
|
private |
Status preserved while Exit crosses nested/event/IRQ boundaries.
Definition at line 1326 of file Thread.h.
Referenced by deferProcessExit(), deferSignalExit(), and takeDeferredProcessExit().
|
private |
|
private |
|
private |
|
private |
Empty, publishing, or pending state for the preallocated exception.
Definition at line 1330 of file Thread.h.
Referenced by deferSubsystemException(), and takeDeferredSubsystemException().
|
private |
|
private |
Nesting depth for deferred event delivery.
Definition at line 1379 of file Thread.h.
Referenced by PerProcessorScheduler::commitCurrentThreadExit(), eventsDeferred(), getNextEvent(), and ~Thread().
Queue of Events ready to run.
Definition at line 1294 of file Thread.h.
Referenced by cullEvent(), cullEvent(), cullSignalEvent(), getNextEvent(), hasEvent(), hasEventsUnlocked(), hasSignalEvent(), markDeferredUserReturnSignalInterruption(), replaceSignalEvent(), sendEvent(), shutdown(), and transferProcessSignalsTo().
|
private |
Drains sendEvent operations admitted before shutdown.
Definition at line 1291 of file Thread.h.
Referenced by replaceSignalEvent(), sendEvent(), and shutdown().
|
private |
sendEvent calls admitted before shutdown closed the event queue.
Definition at line 1297 of file Thread.h.
Referenced by replaceSignalEvent(), sendEvent(), and shutdown().
|
private |
Serialises event queue inspection with waitForEvent().
Definition at line 1288 of file Thread.h.
Referenced by markDeferredUserReturnSignalInterruption(), markSignalInterruptedWait(), replaceSignalEvent(), Process::resume(), sendEvent(), PerProcessorScheduler::serviceProcessStopAtUserReturn(), and wakeForDeliverableEvents().
|
private |
|
private |
One-shot terminal handoff used by the orderly shutdown coordinator.
Definition at line 1314 of file Thread.h.
Referenced by PerProcessorScheduler::abandonCurrentThreadStack(), PerProcessorScheduler::commitCurrentThreadExit(), and PerProcessorScheduler::requestCurrentThreadExitToIdle().
|
private |
Short predicate lock, never held while waking lease drainers.
Definition at line 1268 of file Thread.h.
Referenced by beginExternalLease(), closeExternalLeaseAdmission(), closeExternalLeaseAdmissionAndDrain(), endExternalLease(), markReapable(), and ~Thread().
|
private |
Lifetime barrier for Process::ThreadLease users.
Definition at line 1271 of file Thread.h.
Referenced by closeExternalLeaseAdmissionAndDrain(), and endExternalLease().
|
private |
|
private |
|
private |
Completion queue used by join().
Definition at line 1265 of file Thread.h.
Referenced by Process::beginTermination(), detach(), discardJoin(), endExternalLease(), joinInternal(), markReapable(), Process::prepareThreadExit(), Process::publishTerminationReapable(), shutdown(), startDetached(), and Process::~Process().
|
private |
Lock for schedulers.
Definition at line 1262 of file Thread.h.
Referenced by Process::acquireProcessSignalThread(), PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), adoptInitialUserStackForExec(), commitSignalHandlerMask(), completeAffinityAtSafePoint(), cullEvent(), cullEvent(), cullSignalEvent(), discardUserStackMetadataForExec(), getCurrentSignalDelivery(), getNextEvent(), getSignalMask(), getSignalMaskForReturnFrame(), hasActiveTemporarySignalMask(), hasEvent(), hasSignalEvent(), hasTemporarySignalWaitInterruption(), inhibitEvent(), markDeferredUserReturnSignalInterruption(), markSignalInterruptedWait(), popState(), prepareSignalStateForExec(), pushState(), replaceSignalEvent(), requestAffinity(), restoreDeferredSignalMask(), retainTemporarySignalWaitInterruptionOrClear(), Scheduler::sampleLoadAverage(), sendEvent(), PerProcessorScheduler::serviceProcessStopAtUserReturn(), setClearChildTid(), setCurrentSignalDelivery(), setSignalMask(), setStatus(), setUnwindState(), shutdown(), start(), Thread(), Thread(), transferProcessSignalsTo(), waitAffinity(), and wakeForDeliverableEvents().
|
private |
|
private |
External leases admitted before retirement closed the target.
Definition at line 1274 of file Thread.h.
Referenced by beginExternalLease(), closeExternalLeaseAdmissionAndDrain(), endExternalLease(), markReapable(), and ~Thread().
|
private |
The current index into m_States (head of the state stack).
Definition at line 1177 of file Thread.h.
Referenced by abandonCurrentState(), PerProcessorScheduler::checkEventState(), commitSignalHandlerMask(), executionContext(), getCurrentSignalDelivery(), getKernelStack(), getKernelStackBase(), getSignalMask(), getSignalMaskForReturnFrame(), getWaitDebugInfo(), hasActiveTemporarySignalMask(), hasTemporarySignalWaitInterruption(), inhibitEvent(), interruptWaitUnlocked(), markDeferredUserReturnSignalInterruption(), markSignalInterruptedWait(), markTimeoutInterruptedWait(), popState(), prepareSignalStateForExec(), pushState(), retainTemporarySignalWaitInterruptionOrClear(), setCurrentSignalDelivery(), setKernelStack(), setSignalMask(), state(), Thread(), and Thread().
|
private |
|
private |
|
private |
Per-state LIFO of stack records which teardown must retire explicitly.
Definition at line 1390 of file Thread.h.
Referenced by cleanStateLevel(), PerProcessorScheduler::commitCurrentThreadExit(), popState(), pushState(), and ~Thread().
|
private |
|
private |
Our parent process.
Definition at line 1180 of file Thread.h.
Referenced by accountTimerTick(), cleanStateLevel(), completeAffinityAtSafePoint(), detach(), endExternalLease(), getTlsBase(), getUserspaceTaskId(), joinInternal(), notifySubsystemExit(), publishTimeAccounting(), requestAffinity(), shutdown(), startDetached(), Thread(), Thread(), Thread(), and ~Thread().
|
private |
|
private |
|
private |
|
private |
Memory mapping for the TLS base of this thread (userspace-only)
Definition at line 1249 of file Thread.h.
Referenced by getTlsBase(), resetTlsBase(), setTlsBase(), Thread(), and ~Thread().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Our current status. Sleeping is reserved for an active WaitQueue.
Definition at line 1310 of file Thread.h.
Referenced by Process::acquireProcessSignalThread(), interruptWaitUnlocked(), replaceSignalEvent(), requestAffinity(), sendEvent(), setUnwindState(), start(), Thread(), Thread(), and wakeForDeliverableEvents().
|
private |
Nesting depth for scopes which must run cleanup before teardown.
Definition at line 1387 of file Thread.h.
Referenced by PerProcessorScheduler::commitCurrentThreadExit(), and ~Thread().
|
private |
Per-thread baselines avoid cross-CPU corruption within one Process.
Definition at line 1192 of file Thread.h.
Referenced by recordTime(), trackTime(), and transitionTime().
|
private |
|
private |
|
private |
CPU time charged to this Thread, split by user and kernel mode.
Definition at line 1195 of file Thread.h.
Referenced by publishTimeAccounting().