|
The Pedigree Project 0.1
|
#include <Process.h>
Inheritance diagram for Process:
Collaboration diagram for Process:Classes | |
| struct | ChildTransition |
| class | ControllingTerminal |
| struct | DeferredPublication |
| class | ExecScope |
| class | FileContextLease |
| class | FilesystemAccessScope |
| struct | ProcessMetadata |
| class | ReaperClaim |
| class | TerminalOwnerReservation |
| class | ThreadCreationScope |
| class | ThreadLease |
| struct | UserReservationSnapshot |
| class | VforkCompletion |
Public Types | |
| enum | ProcessType { Stock , Posix } |
| enum | ProcessState { Active , Suspended , Terminating , Terminated , Reaped } |
| enum class | ChildTransitionKind { None , Stopped , Continued } |
| enum class | FilesystemContextMode { Inherit , Deferred } |
| enum class | UserRegion { Normal , Dynamic } |
Static Public Member Functions | |
| static SharedPointer< UserspacePidNamespace > | rootPidNamespace () |
| static bool | currentFilesystemCredentials (FilesystemCredentials &out) |
| static Process * | getInit () |
| static void | setInit (Process *pProcess) |
Protected Member Functions | |
| void | publishAccountIdentity (User *, Group *) |
| Process (DeferredPublication, ProcessType type=Stock) | |
| Process (DeferredPublication, Process *pParent, bool bCopyOnWrite=true, FilesystemContextMode filesystemContext=FilesystemContextMode::Inherit, bool emptyAddressSpace=false, ProcessType type=Stock) | |
| void | publish () |
| void | prepareForDestruction () |
| void | enableTimeAccountingReports (size_t initialInterest=~size_t(0)) |
| void | setTimeAccountingReportInterest (size_t interest, bool enabled) |
Static Protected Member Functions | |
| static bool | loadFilesystemIds (const Thread &, uint32_t &uid, uint32_t &gid) |
| static void | publishFilesystemIds (Thread &, uint32_t uid, uint32_t gid) |
Protected Attributes | |
| Spinlock | m_CredentialLock |
Private Types | |
| enum | ReaperState { ReaperUnclaimed , ReaperClaimed , ReaperPublished } |
Private Member Functions | |
| void | finishTermination (bool abandonStack, bool notifyParent) NORETURN |
| Process (const Process &) | |
| Process & | operator= (const Process &) |
| virtual void | reportTimesUpdated (Time::Timestamp userTotal, Time::Timestamp total) |
| void | drainDeferredTimeAccounting () |
| void | closeDeferredTimeAccounting () |
| Time::Timestamp | totalTime (CpuTimeMode mode) const |
| ALWAYS_INLINE void | reportTimeAccounting (Time::Timestamp elapsed) |
| void | queueTimeAccountingReport (Time::Timestamp elapsed) |
| virtual void | processTerminated () |
| bool | transitionState (ProcessState expected, ProcessState desired) |
| void | suspendInternal (int stopSignal, bool checkContinuationEpoch, size_t continuationEpoch) |
| void | transitionToTerminating () |
| bool | terminatingThreadReapable (Thread *pThread, bool &wakeOwner) |
| void | publishTerminationStatus (bool notifyParent) |
| void | publishTerminationReapable () |
| void | publishReaperClaim () |
| bool | beginThreadJoin () |
| void | endThreadJoin () |
| bool | beginExternalLease () |
| void | endExternalLease () |
| void | closeExternalLeaseAdmission () |
| void | drainExternalLeases () |
| void | releaseThreadLease (Thread *thread) |
| void | installTerminalOwner (Thread *owner) |
Static Private Attributes | |
| static Process * | m_pInitProcess = 0 |
Friends | |
| class | PerProcessorScheduler |
| class | Scheduler |
| class | Thread |
| class | ZombieProcess |
| class | ZombieQueue |
An abstraction of a Process - a container for one or more threads all running in the same address space.
| enum Process::ProcessType |
Subsystems may inherit Process to provide custom functionality. However, they need to know whether a Process pointer is subsystem-specific. This enumeration is designed to allow functions using Process objects in subsystems with inherited Process objects to be able to figure out what type the Process is without depending on any external accounting.
| Process::Process | ( | ) |
| Process::Process | ( | Process * | pParent, |
| bool | bCopyOnWrite = true |
||
| ) |
Constructor for creating a new Process. Creates a new Process as a UNIX fork() would, from the given parent process. This constructor does not create any threads.
| pParent | The parent process. |
| bCopyOnWrite | Whether to mark the address space copy-on-write (default) or to share it read/write with the new child. |
Definition at line 564 of file Process.cc.
References publish().
|
virtual |
Destructor.
Definition at line 1080 of file Process.cc.
References Subsystem::acquire(), Vector< T >::begin(), OperationBarrier::closeAndWait(), Thread::closeExternalLeaseAdmissionAndDrain(), Dec, Vector< T >::end(), Thread::getId(), ProcessorBase::getInterrupts(), Thread::getStatus(), Thread::getUserTime(), ProcessorBase::information(), m_bDestroying, Thread::m_bJoinClaimed, Thread::m_bReapable, m_bThreadJoinAdmissionClosed, m_DeferredThreadReaps, m_Id, Thread::m_JoinWaiters, m_Lock, m_nThreadJoinOperations, m_pAddressSpace, m_pSubsystem, m_ThreadJoinWaiters, m_Threads, m_TimeAccountingLock, prepareForDestruction(), VirtualAddressSpace::revertToKernelAddressSpace(), ProcessorBase::setInterrupts(), str, ProcessorBase::switchAddressSpace(), Process::ProcessMetadata::userTime, and WaitQueue::Guard::waitForCompletion().
|
protected |
Definition at line 498 of file Process.cc.
|
protected |
Definition at line 569 of file Process.cc.
| void Process::accountReapedChild | ( | const Process * | child, |
| Time::Timestamp & | user, | ||
| Time::Timestamp & | kernel | ||
| ) |
Adds a reaped child's final self and descendant CPU totals to this process. The caller must own the child's sole reaper claim and wait until it is termination-reapable before calling this exactly once.
Definition at line 857 of file Process.cc.
References getUserTime(), Reaped, Process::ProcessMetadata::reapedChildrenKernelTime, and Process::ProcessMetadata::reapedChildrenUserTime.
|
inline |
| File * Process::acquireCtty | ( | FileContextLease & | lease | ) | const |
Definition at line 800 of file Process.cc.
| SharedPointer< Process::ControllingTerminal > Process::acquireCttyContext | ( | ) | const |
Definition at line 795 of file Process.cc.
| FilesystemContextRef Process::acquireFilesystemContext | ( | ) | const |
Definition at line 729 of file Process.cc.
| bool Process::acquireProcessSignalThread | ( | ThreadLease & | lease | ) |
Pins a live process-signal recipient, preferring an admitted exec owner.
Definition at line 1407 of file Process.cc.
References beginExternalLease(), Thread::beginExternalLease(), endExternalLease(), Thread::getUnwindState(), Thread::m_bShutdown, m_Lock, Thread::m_Lock, m_pExecOwner, Thread::m_Status, m_Threads, and Thread::TerminateThread.
Referenced by beginTermination(), PosixSubsystem::preserveProcessSignalsForThreadExit(), publishTerminationStatus(), PosixSubsystem::queueSignalDelivery(), IntervalTimer::signal(), and suspendInternal().
Here is the caller graph for this function:| bool Process::acquireThread | ( | ThreadLease & | lease, |
| size_t | n | ||
| ) |
Pins the n'th thread in this process into lease. Any previous lease is released; failure leaves lease empty.
Definition at line 1385 of file Process.cc.
References beginExternalLease(), Thread::beginExternalLease(), Vector< T >::count(), endExternalLease(), m_Lock, and m_Threads.
Referenced by MemoryPressureProcessKiller::compact(), PosixSubsystem::prepareThreadsForExec(), PosixSubsystem::queueSignalDelivery(), resume(), and PosixSubsystem::setSignalHandler().
Here is the caller graph for this function:| bool Process::acquireThread | ( | ThreadLease & | lease, |
| Thread * | expected | ||
| ) |
Pins an expected Thread into lease if this Process still owns it. Any previous lease is released; failure leaves lease empty.
Definition at line 1528 of file Process.cc.
References Vector< T >::begin(), beginExternalLease(), Thread::beginExternalLease(), Vector< T >::end(), endExternalLease(), m_Lock, and m_Threads.
| bool Process::acquireThreadById | ( | ThreadLease & | lease, |
| size_t | id | ||
| ) |
Pins the thread whose process-local identifier is id into lease. Any previous lease is released; failure leaves lease empty.
Definition at line 1446 of file Process.cc.
References Vector< T >::begin(), beginExternalLease(), Thread::beginExternalLease(), Vector< T >::end(), endExternalLease(), m_Lock, and m_Threads.
| bool Process::acquireThreadByTaskId | ( | ThreadLease & | lease, |
| size_t | id | ||
| ) |
Definition at line 1473 of file Process.cc.
| bool Process::acquireThreadByUserspaceId | ( | ThreadLease & | lease, |
| size_t | id, | ||
| const UserspacePidNamespace * | space | ||
| ) |
Definition at line 1500 of file Process.cc.
|
inline |
The waiting creator keeps this owner and its image alive until detach.
Definition at line 545 of file Process.h.
Referenced by X64PreparedPageRemap::commit().
Here is the caller graph for this function:| size_t Process::addThread | ( | Thread * | pThread | ) |
Adds a thread to this process.
Definition at line 1303 of file Process.cc.
References Dec, Scheduler::instance(), m_bDestroying, Thread::m_bProcessExitOwned, Thread::m_bProcessExitParticipant, m_bTerminationSealed, m_Id, m_Lock, m_NextTid, m_nTerminationParticipants, m_Threads, m_TimeAccountingLock, m_UserspaceNamespace, m_UserspacePid, Vector< T >::pushBack(), Reaped, Scheduler::reserveProcessId(), Thread::TerminateThread, and SharedPointer< T >::tryAllocate().
Referenced by Thread::Thread(), Thread::Thread(), and Thread::Thread().
Here is the caller graph for this function:| bool Process::allocateSpecificUserRange | ( | UserRegion | region, |
| uintptr_t | address, | ||
| size_t | length | ||
| ) |
Definition at line 132 of file Process-reservations.cc.
| bool Process::allocateUserRange | ( | UserRegion | region, |
| size_t | length, | ||
| uintptr_t & | address | ||
| ) |
Definition at line 101 of file Process-reservations.cc.
|
private |
Pins this Process while it remains in scheduler enumeration.
Definition at line 1200 of file Process.cc.
References m_bExternalLeaseAdmissionClosed, m_ExternalLeaseLock, and m_nExternalLeases.
Referenced by Scheduler::acquireFirstProcessOfType(), Scheduler::acquireProcess(), Scheduler::acquireProcess(), Scheduler::acquireProcessById(), acquireProcessSignalThread(), acquireThread(), acquireThread(), acquireThreadById(), Scheduler::acquireThreadByTaskId(), beginTermination(), Thread::completeAffinityAtSafePoint(), Scheduler::drainDeferredTimeAccounting(), Thread::requestAffinity(), and Scheduler::sampleLoadAverage().
Here is the caller graph for this function:| bool Process::beginTermination | ( | int | code = 0, |
| Subsystem::ExitCause | cause = Subsystem::ExitCause::Normal |
||
| ) |
Atomically elects the current thread to own process exit and requests thread-only termination for every peer. Returns true only to the elected owner (including its nested-event re-entry).
Definition at line 1685 of file Process.cc.
References Spinlock::acquire(), acquireProcessSignalThread(), Vector< T >::begin(), beginExternalLease(), Thread::beginExternalLease(), closeDeferredTimeAccounting(), Dec, Vector< T >::end(), SharedPointer< T >::get(), Scheduler::getChildProcess(), getId(), Thread::getId(), getParent(), Thread::getParent(), getUserspaceId(), ProcessorBase::information(), Scheduler::instance(), Subsystem::kill(), Thread::m_bExitStarted, Thread::m_bProcessExitOwned, Thread::m_bProcessExitParticipant, Thread::m_bReapable, m_bTerminalOwnerReserved, m_bTerminationReapable, m_bTerminationRendezvousStarted, m_bTerminationSealed, m_ChildStateWaiters, m_Id, Thread::m_JoinWaiters, m_Lock, m_nTerminationParticipants, m_pExecOwner, m_pInitProcess, m_pParent, m_pReservedTerminalOwner, m_pTerminatingThread, m_TerminationWaiters, m_Threads, m_UserspaceNamespace, Vector< T >::pushBack(), Spinlock::release(), Thread::TerminateThread, transitionToTerminating(), and waitUntilTerminationReapable().
Referenced by PosixSubsystem::exit(), and kill().
Here is the caller graph for this function:
|
private |
Pins this Process and its retained Thread objects for Thread::join.
Definition at line 1178 of file Process.cc.
References m_bThreadJoinAdmissionClosed, m_nThreadJoinOperations, and m_ThreadJoinWaiters.
Referenced by Thread::detach(), Thread::joinInternal(), and Thread::startDetached().
Here is the caller graph for this function:| void Process::borrowVforkAddressSpace | ( | Process & | parent, |
| const SharedPointer< VforkCompletion > & | completion | ||
| ) |
Definition at line 702 of file Process.cc.
|
private |
Stops timer-report admission and discards any unpublished residue.
Definition at line 938 of file Process.cc.
References OperationBarrier::closeAndWait(), m_bTimeAccountingReportsEnabled, m_DeferredTimeAccounting, m_TimeAccountingReports, and DeferredTimeAccounting::take().
Referenced by beginTermination(), and prepareForDestruction().
Here is the caller graph for this function:
|
private |
Prevents any further ProcessLease or ThreadLease acquisition.
Definition at line 1273 of file Process.cc.
References m_bExternalLeaseAdmissionClosed, and m_ExternalLeaseLock.
Referenced by prepareForDestruction(), and Scheduler::removeProcess().
Here is the caller graph for this function:| bool Process::commitUserReservations | ( | uint64_t | expectedGeneration, |
| UserReservationSnapshot & | replacement | ||
| ) |
A successful swap leaves old storage in replacement for unlocked destruction.
Definition at line 86 of file Process-reservations.cc.
References commitUserReservations(), m_DynamicSpaceAllocator, m_SpaceAllocator, and RangeList< T, Reversed >::swap().
Referenced by commitUserReservations().
Here is the caller graph for this function:| bool Process::createPidNamespace | ( | ) |
Definition at line 106 of file Process.cc.
|
static |
Definition at line 47 of file Process-credentials.cc.
|
inline |
Returns the description string of this process.
Definition at line 525 of file Process.h.
Referenced by PosixSubsystem::invoke(), and Rtc::processElapsedTime().
Here is the caller graph for this function:
|
private |
Drains one coalesced batch from an ordinary accounting worker.
Definition at line 925 of file Process.cc.
References getUserTime(), m_DeferredTimeAccounting, m_TimeAccountingReports, reportTimesUpdated(), DeferredTimeAccounting::take(), and OperationBarrier::tryAcquire().
Referenced by Scheduler::drainDeferredTimeAccounting().
Here is the caller graph for this function:
|
private |
Waits until all leases admitted before closure have left scope.
Definition at line 1278 of file Process.cc.
References m_bExternalLeaseAdmissionClosed, m_bExternalLeaseReleaseInProgress, m_ExternalLeaseLock, m_ExternalLeaseWaiters, and m_nExternalLeases.
Referenced by prepareForDestruction().
Here is the caller graph for this function:
|
protected |
Enables deferred timer reporting for a derived process type.
Definition at line 839 of file Process.cc.
References m_bTimeAccountingReportsEnabled.
Referenced by PosixProcess::PosixProcess().
Here is the caller graph for this function:
|
private |
Releases a scheduler or ThreadLease pin.
Definition at line 1210 of file Process.cc.
References Dec, m_bExternalLeaseAdmissionClosed, m_bExternalLeaseReleaseInProgress, m_ExternalLeaseLock, m_ExternalLeaseWaiters, m_Id, and m_nExternalLeases.
Referenced by acquireProcessSignalThread(), acquireThread(), acquireThread(), acquireThreadById(), Thread::completeAffinityAtSafePoint(), Scheduler::drainDeferredTimeAccounting(), Scheduler::releaseProcessLease(), releaseThreadLease(), and Thread::requestAffinity().
Here is the caller graph for this function:
|
private |
Releases a successful beginThreadJoin admission.
Definition at line 1188 of file Process.cc.
References Dec, m_Id, m_nThreadJoinOperations, and m_ThreadJoinWaiters.
Referenced by Thread::detach(), Thread::discardJoin(), Thread::joinInternal(), and Thread::startDetached().
Here is the caller graph for this function:| bool Process::filesystemContextReady | ( | ) | const |
Definition at line 764 of file Process.cc.
|
private |
Definition at line 1929 of file Process.cc.
| void Process::finishTermination | ( | bool | notifyParent = false | ) |
Completes an elected teardown and retires the current thread.
Definition at line 1925 of file Process.cc.
References finishTermination().
Referenced by PosixSubsystem::exit(), finishTermination(), and kill().
Here is the caller graph for this function:| void Process::freeUserRange | ( | UserRegion | region, |
| uintptr_t | address, | ||
| size_t | length | ||
| ) |
Definition at line 161 of file Process-reservations.cc.
|
inline |
Returns our address space
Definition at line 530 of file Process.h.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), Thread::cleanStateLevel(), MemoryMapManager::clone(), X64PreparedPageRemap::commit(), X64VirtualAddressSpace::detachEmptyTables(), PosixSubsystem::exit(), Thread::getTlsBase(), X64VirtualAddressSpace::invalidateMapping(), PosixSubsystem::invoke(), X64VirtualAddressSpace::mapUnlocked(), Thread::notifySubsystemExit(), PosixSubsystem::resolveUserPageFault(), PosixSubsystem::setProcess(), PosixSubsystem::~PosixSubsystem(), and Thread::~Thread().
Here is the caller graph for this function:| size_t Process::getContinuationEpoch | ( | ) |
Snapshots the generation invalidated by every process continuation.
Definition at line 2150 of file Process.cc.
References m_ContinuationEpoch, and m_SuspensionWaiters.
| Group * Process::getEffectiveGroup | ( | ) | const |
Gets the current effective group.
Definition at line 122 of file Process-credentials.cc.
References m_pEffectiveGroup.
|
virtual |
Definition at line 2253 of file Process.cc.
| User * Process::getEffectiveUser | ( | ) | const |
Gets the effective user.
Definition at line 112 of file Process-credentials.cc.
References m_pEffectiveUser.
|
virtual |
Definition at line 2248 of file Process.cc.
|
inline |
Gets the exit status of the process.
Definition at line 560 of file Process.h.
Referenced by PosixSubsystem::queueSignalDelivery().
Here is the caller graph for this function:| Group * Process::getGroup | ( | ) | const |
Gets the current group.
Definition at line 117 of file Process-credentials.cc.
References m_pGroup.
Referenced by ProcFs::addProcess().
Here is the caller graph for this function:
|
virtual |
Definition at line 2243 of file Process.cc.
|
inline |
Get process usage.
Definition at line 902 of file Process.h.
Referenced by Rtc::processElapsedTime().
Here is the caller graph for this function:
|
inline |
Returns the process ID.
Definition at line 499 of file Process.h.
Referenced by Scheduler::acquireProcessById(), Scheduler::acquireThreadByTaskId(), beginTermination(), MemoryPressureProcessKiller::compact(), PosixSubsystem::exit(), Thread::getTlsBase(), Thread::getUserspaceTaskId(), ProcFs::initialise(), X64InterruptManager::interrupt(), PosixSubsystem::invoke(), PosixSubsystem::kill(), Rtc::processElapsedTime(), File::publishEvent(), PosixSubsystem::sendSignal(), and PosixSubsystem::threadException().
Here is the caller graph for this function:
|
static |
Get the init process (first userspace process, parent of all userspace processes).
Definition at line 2417 of file Process.cc.
References m_pInitProcess.
|
inline |
| size_t Process::getNumThreads | ( | ) |
Returns the number of threads in this process.
Definition at line 1380 of file Process.cc.
References Vector< T >::count(), m_Lock, and m_Threads.
Referenced by ThreadsCommand::execute(), PosixSubsystem::prepareThreadsForExec(), PosixSubsystem::queueSignalDelivery(), PosixSubsystem::resetSignalHandlersForExec(), resume(), PosixSubsystem::setSignalHandler(), and PosixSubsystem::~PosixSubsystem().
Here is the caller graph for this function:
|
inline |
Returns the parent process.
Definition at line 620 of file Process.h.
Referenced by Elf::allocate(), MemoryMapManager::allows(), beginTermination(), UnixSocketSyscalls::bind(), RandomFile::command(), Scheduler::getChildProcess(), UserManager::initialise(), CacheManager::initialise(), PosixSubsystem::loadElf(), ConsoleManager::lockConsole(), prepareForDestruction(), publish(), publishTerminationStatus(), PosixSubsystem::queueSignalDelivery(), MemoryMapManager::removeAndRelease(), MemoryMapManager::removeAttachment(), DynamicLinker::resolvePlt(), resume(), pocketknife::runConcurrentlyAttached(), suspendInternal(), and ConsoleManager::unlockConsole().
Here is the caller graph for this function:
|
inline |
|
inline |
|
inline |
|
virtual |
Definition at line 2258 of file Process.cc.
|
inline |
| User * Process::getUser | ( | ) | const |
Gets the current user.
Definition at line 107 of file Process-credentials.cc.
Referenced by ProcFs::addProcess(), and getUserId().
Here is the caller graph for this function:
|
virtual |
Direct, overrideable ways to get IDs (redirects to User/Group interface by default)
Reimplemented in PosixProcess.
Definition at line 2238 of file Process.cc.
References getUser().
Referenced by PosixSubsystem::invoke(), and PosixSubsystem::queueSignalDelivery().
Here is the caller graph for this function:
|
inline |
Returns the process ID exposed to userspace.
Definition at line 504 of file Process.h.
Referenced by ProcFs::addProcess(), beginTermination(), Thread::getUserspaceTaskId(), PosixSubsystem::invoke(), publish(), PosixSubsystem::queueSignalDelivery(), and PosixSubsystem::threadExiting().
Here is the caller graph for this function:
|
inline |
|
inline |
Gets timestamps.
Definition at line 829 of file Process.h.
Referenced by accountReapedChild(), drainDeferredTimeAccounting(), and PosixSubsystem::queueSignalDelivery().
Here is the caller graph for this function:
|
inline |
Definition at line 58 of file Process-credentials.cc.
| bool Process::installFilesystemContext | ( | FilesystemContextOwner && | context | ) |
Install into an empty slot; failure leaves the staged owner untouched.
Definition at line 734 of file Process.cc.
References m_FilesystemContextLock.
|
private |
Installs the Thread which alone may consume a terminal reservation.
Definition at line 1592 of file Process.cc.
References Vector< T >::begin(), Thread::Continue, Dec, Vector< T >::end(), m_bTerminalOwnerReserved, m_Id, m_Lock, m_pReservedTerminalOwner, and m_Threads.
Referenced by Process::TerminalOwnerReservation::install().
Here is the caller graph for this function:
|
virtual |
Definition at line 72 of file Process-credentials.cc.
| void Process::kill | ( | ) |
Performs the complete election, quiesce, and teardown sequence.
Definition at line 2019 of file Process.cc.
References beginTermination(), Dec, finishTermination(), ProcessorBase::information(), m_Id, and quiesceTermination().
|
staticprotected |
Definition at line 9 of file Process-credentials.cc.
| void Process::markTerminating | ( | ) |
Definition at line 1649 of file Process.cc.
|
inline |
|
inline |
| SharedPointer< UserspacePidNamespace > Process::pidNamespaceForChildren | ( | ) |
Definition at line 87 of file Process.cc.
| bool Process::pidNamespaceReady | ( | ) | const |
Definition at line 94 of file Process.cc.
|
protected |
Removes this process from enumeration and drains inspectors.
Every derived destructor must call this before touching down its own members; the base destructor runs too late to protect derived storage.
Definition at line 1029 of file Process.cc.
References closeDeferredTimeAccounting(), closeExternalLeaseAdmission(), drainExternalLeases(), getParent(), Scheduler::instance(), m_bPublished, m_bUnregistered, m_ChildStateWaiters, m_pInitProcess, and Scheduler::removeProcess().
Referenced by ~Process().
Here is the caller graph for this function:| bool Process::prepareThreadExit | ( | ) |
Reserves process teardown if this is the final requested thread exit.
Definition at line 1654 of file Process.cc.
References Thread::getParent(), Thread::getUnwindState(), ProcessorBase::information(), Thread::m_bExitStarted, Thread::m_bReapable, m_bTerminalOwnerReserved, m_bTerminationRendezvousStarted, Thread::m_bThreadExitRequested, Thread::m_JoinWaiters, m_Lock, m_pReservedTerminalOwner, m_Threads, Thread::TerminateThread, and transitionToTerminating().
|
inlineprivatevirtual |
Called when the process is terminated to allow for subclass cleanup.
Reimplemented in PosixProcess.
|
protected |
Makes a completely constructed Process visible to enumeration.
Definition at line 944 of file Process.cc.
References Scheduler::addProcess(), getParent(), getUserspaceId(), Scheduler::instance(), m_bPublished, m_ChildStateWaiters, m_pParent, and m_UserspaceNamespace.
Referenced by Process(), Process(), and PosixProcess::publish().
Here is the caller graph for this function:Definition at line 67 of file Process-credentials.cc.
|
staticprotected |
Definition at line 17 of file Process-credentials.cc.
|
private |
Publishes a previously claimed deferred destruction exactly once.
Definition at line 2010 of file Process.cc.
References m_ReaperState.
|
private |
Publishes the scheduler's final off-stack destruction barrier.
Definition at line 2385 of file Process.cc.
References Vector< T >::begin(), Dec, Vector< T >::end(), Thread::getId(), Thread::m_bReapable, m_bTerminationReapable, m_Id, Thread::m_JoinWaiters, m_Lock, m_nTerminationParticipants, m_pTerminatingThread, m_TerminationWaiters, m_Threads, and Reaped.
|
private |
Publishes terminal wait status while the elected owner is still live.
Definition at line 2329 of file Process.cc.
References acquireProcessSignalThread(), Dec, getParent(), Scheduler::instance(), m_ChildStateWaiters, m_Id, m_PendingChildTransition, m_SuspensionWaiters, Subsystem::threadException(), and transitionState().
|
private |
Definition at line 894 of file Process.cc.
| bool Process::quiesceTermination | ( | ) |
Claims shared teardown for the elected owner and waits until every peer is off-stack. Exactly one call can succeed.
Definition at line 1875 of file Process.cc.
References Spinlock::acquire(), Dec, ProcessorBase::information(), m_bTerminationCleanupStarted, m_bTerminationRendezvousStarted, m_bTerminationSealed, m_Id, m_Lock, m_nTerminationParticipants, m_pTerminatingThread, m_TerminationWaiters, and Spinlock::release().
Referenced by PosixSubsystem::exit(), and kill().
Here is the caller graph for this function:| void Process::reap | ( | ) |
Marks the process as reaped.
Callers must hold the parent's child-state wait guard so only one concurrent wait operation can claim the status.
Definition at line 1642 of file Process.cc.
References Dec, m_Id, Reaped, and transitionState().
| void Process::releaseFilesystemContext | ( | ) |
Definition at line 769 of file Process.cc.
|
private |
Releases both halves of an admitted ThreadLease.
Definition at line 1296 of file Process.cc.
References endExternalLease(), and Thread::endExternalLease().
| void Process::releaseVforkAddressSpace | ( | ) |
Caller holds the mapping operation guard and has retired user-memory hooks.
Definition at line 711 of file Process.cc.
References ProcessorBase::getInterrupts(), Thread::getParent(), ProcessorBase::information(), m_pAddressSpace, ProcessorBase::setInterrupts(), and ProcessorBase::switchAddressSpace().
Referenced by PosixSubsystem::exit(), PosixSubsystem::invoke(), and PosixSubsystem::~PosixSubsystem().
Here is the caller graph for this function:| void Process::removeThread | ( | Thread * | pThread | ) |
Removes a thread from this process.
Definition at line 1351 of file Process.cc.
References Vector< T >::begin(), Vector< T >::end(), Vector< T >::erase(), Thread::getUserTime(), m_bDestroying, m_Lock, m_pSubsystem, m_Threads, m_TimeAccountingLock, Subsystem::threadRemoved(), and Process::ProcessMetadata::userTime.
Referenced by Thread::~Thread().
Here is the caller graph for this function:| bool Process::replaceFilesystemContext | ( | FilesystemContextOwner && | replacement, |
| const FilesystemContextRef & | expected | ||
| ) |
Definition at line 746 of file Process.cc.
|
inlineprivate |
|
inlineprivatevirtual |
Called by the accounting worker with absolute userspace and total time. This is never invoked by trackTime() or while scheduler locks are held.
Reimplemented in PosixProcess.
Definition at line 984 of file Process.h.
Referenced by drainDeferredTimeAccounting().
Here is the caller graph for this function:| Process::TerminalOwnerReservation Process::reserveTerminalOwner | ( | ) |
Reserves the Active/Suspended lifecycle while a terminal owner is constructed. Competing exit attempts take the thread-only path until the installed owner enters process termination.
Definition at line 1560 of file Process.cc.
References Spinlock::acquire(), Dec, m_bDestroying, m_bTerminalOwnerReserved, m_bTerminationRendezvousStarted, m_bTerminationSealed, m_Id, m_Lock, m_pReservedTerminalOwner, Reaped, and Spinlock::release().
| void Process::resetUserReservations | ( | ) |
Definition at line 197 of file Process-reservations.cc.
| void Process::resume | ( | ) |
Resumes the process from suspend.
Definition at line 2155 of file Process.cc.
References acquireThread(), getNumThreads(), getParent(), Scheduler::instance(), m_ChildStateWaiters, m_ContinuationEpoch, Thread::m_EventWaiters, m_PendingChildTransition, m_SuspensionWaiters, transitionState(), and Thread::wakeForDeliverableEvents().
Referenced by PosixSubsystem::queueSignalDelivery().
Here is the caller graph for this function:
|
static |
Definition at line 83 of file Process.cc.
| bool Process::selectPendingChildTransition | ( | bool | includeStopped, |
| bool | includeContinued, | ||
| bool | consume, | ||
| ChildTransition & | transition | ||
| ) |
Selects a pending child transition, optionally consuming it. Unrequested transitions remain pending; a miss clears the output. The caller holds the parent's child-state guard.
Definition at line 2215 of file Process.cc.
References m_PendingChildTransition, and m_SuspensionWaiters.
Referenced by takePendingChildTransition().
Here is the caller graph for this function:| bool Process::setCtty | ( | File * | file | ) |
Null is infallible; a positive install can fail to retain or allocate.
Definition at line 820 of file Process.cc.
References File::releaseVfsReference(), File::retainVfsReference(), and SharedPointer< T >::tryAdopt().
| void Process::setCttyContext | ( | const SharedPointer< ControllingTerminal > & | context | ) |
Definition at line 810 of file Process.cc.
| void Process::setEffectiveGroup | ( | Group * | pGroup | ) |
Definition at line 145 of file Process-credentials.cc.
|
virtual |
Definition at line 2268 of file Process.cc.
| void Process::setEffectiveUser | ( | User * | pUser | ) |
Sets the effective user.
Definition at line 133 of file Process-credentials.cc.
References m_NativeFilesystemCredentials, and m_pEffectiveUser.
|
virtual |
Definition at line 2266 of file Process.cc.
|
inline |
Sets the exit status of the process.
Definition at line 556 of file Process.h.
Referenced by PosixSubsystem::exit().
Here is the caller graph for this function:| void Process::setGroup | ( | Group * | pGroup | ) |
Sets the current group.
Definition at line 139 of file Process-credentials.cc.
References m_NativeFilesystemCredentials, and m_pGroup.
|
virtual |
Definition at line 2264 of file Process.cc.
|
static |
|
inline |
|
inline |
|
protected |
Changes independently owned report-interest bits without losing pending work.
Definition at line 844 of file Process.cc.
References ProcessorBase::information(), m_bTimeAccountingReportsEnabled, m_DeferredTimeAccounting, and DeferredTimeAccounting::publish().
| void Process::setUser | ( | User * | pUser | ) |
Sets the current user.
Definition at line 127 of file Process-credentials.cc.
References m_NativeFilesystemCredentials.
|
virtual |
Definition at line 2262 of file Process.cc.
|
virtual |
Definition at line 23 of file Process-credentials.cc.
| bool Process::snapshotUserReservations | ( | UserReservationSnapshot & | result | ) |
Definition at line 16 of file Process-reservations.cc.
| void Process::suspend | ( | int | stopSignal = 0 | ) |
| void Process::suspendIfContinuationEpoch | ( | int | stopSignal, |
| size_t | continuationEpoch | ||
| ) |
Suspends only if no continuation has occurred since the stop was queued.
Definition at line 2055 of file Process.cc.
References suspendInternal().
|
private |
Shared implementation for unconditional and generation-checked stops.
Definition at line 2059 of file Process.cc.
References acquireProcessSignalThread(), getParent(), Thread::getParent(), Thread::getScheduler(), ProcessorBase::information(), Scheduler::instance(), m_ChildStateWaiters, m_ContinuationEpoch, m_PendingChildTransition, m_SuspensionWaiters, PerProcessorScheduler::serviceProcessStopAtUserReturn(), Subsystem::threadException(), transitionState(), and WaitQueue::Guard::wait().
Referenced by suspend(), and suspendIfContinuationEpoch().
Here is the caller graph for this function:| bool Process::takePendingChildTransition | ( | bool | includeStopped, |
| bool | includeContinued, | ||
| ChildTransition & | transition | ||
| ) |
Consuming compatibility entry point for existing child waiters.
Definition at line 2233 of file Process.cc.
References selectPendingChildTransition().
|
private |
Accounts for one process-exit participant after it is off-stack. The caller holds m_Lock. Returns true for the last participant and sets wakeOwner when an elected owner may be waiting for peer progress.
Definition at line 2308 of file Process.cc.
References Dec, Thread::getId(), Thread::m_bProcessExitParticipant, m_bTerminationRendezvousStarted, m_bTerminationSealed, m_Id, and m_nTerminationParticipants.
| void Process::threadExiting | ( | Thread * | pThread | ) |
Runs subsystem cleanup while the exiting thread and address space live.
Definition at line 1336 of file Process.cc.
References m_pSubsystem, and Subsystem::threadExiting().
Referenced by Thread::notifySubsystemExit().
Here is the caller graph for this function:
|
private |
Aggregates live threads and retired totals without taking the topology lock.
Definition at line 900 of file Process.cc.
References Thread::getUserTime(), m_bDestroying, m_Threads, m_TimeAccountingLock, and Process::ProcessMetadata::userTime.
|
inline |
| void Process::transferExecProcessSignals | ( | Thread * | pThread | ) |
Preserves process-owned signals before an exiting thread drains its queue.
Definition at line 1342 of file Process.cc.
References m_pSubsystem, and Subsystem::preserveProcessSignalsForThreadExit().
Referenced by Thread::shutdown().
Here is the caller graph for this function:
|
private |
Changes process state only if it still matches the expected state. Active and Suspended may alternate, but no caller may overwrite a terminal lifecycle transition.
Definition at line 1621 of file Process.cc.
References m_State.
Referenced by publishTerminationStatus(), reap(), resume(), suspendInternal(), and transitionToTerminating().
Here is the caller graph for this function:
|
private |
Advances Active or Suspended to Terminating without downgrading.
Definition at line 1626 of file Process.cc.
References Dec, m_Id, and transitionState().
Referenced by beginTermination(), and prepareThreadExit().
Here is the caller graph for this function:| Process::ReaperClaim Process::tryClaimReaper | ( | ) |
Claims the sole deferred-destruction publication for this Process.
Definition at line 2001 of file Process.cc.
References m_ReaperState.
| bool Process::unsharePidNamespace | ( | ) |
Definition at line 122 of file Process.cc.
| bool Process::unsharePidNamespace | ( | const SharedPointer< UserspacePidNamespace > & | prepared | ) |
Definition at line 130 of file Process.cc.
| bool Process::waitUntilTerminationReapable | ( | ) |
Blocks a deferred reaper until the terminating thread is off-stack. Returns false rather than self-deadlocking if called by that thread.
Definition at line 2270 of file Process.cc.
References ProcessorBase::information(), m_bTerminationReapable, m_pTerminatingThread, m_TerminationWaiters, and WaitQueue::Guard::waitForCompletion().
Referenced by beginTermination().
Here is the caller graph for this function:| bool Process::waitUntilTerminationReapableForTerminalCoordinator | ( | ) |
Polls terminal completion without sleeping the shutdown coordinator. This keeps it runnable as the last same-CPU exit owner's successor.
Definition at line 2292 of file Process.cc.
References ProcessorBase::information(), Scheduler::instance(), m_bTerminationReapable, m_pTerminatingThread, m_TerminationWaiters, and Scheduler::yield().
|
friend |
|
friend |
|
friend |
|
private |
Process destruction is iterating m_Threads and owns its cleanup.
Definition at line 1155 of file Process.h.
Referenced by addThread(), removeThread(), reserveTerminalOwner(), totalTime(), and ~Process().
|
private |
Whether scheduler removal has closed Process lease admission.
Definition at line 1127 of file Process.h.
Referenced by beginExternalLease(), closeExternalLeaseAdmission(), drainExternalLeases(), and endExternalLease().
|
private |
Whether a closed final release is completing its waiter handoff.
Definition at line 1130 of file Process.h.
Referenced by drainExternalLeases(), and endExternalLease().
|
private |
Whether this object has been published to scheduler enumeration.
Definition at line 1158 of file Process.h.
Referenced by prepareForDestruction(), and publish().
|
private |
|
private |
A dedicated exit owner is being constructed or waiting to run.
Definition at line 1180 of file Process.h.
Referenced by beginTermination(), installTerminalOwner(), prepareThreadExit(), and reserveTerminalOwner().
|
private |
The elected owner has exclusively claimed shared process teardown.
Definition at line 1186 of file Process.h.
Referenced by quiesceTermination().
|
private |
Whether the scheduler has completed the terminating thread switch.
Definition at line 1192 of file Process.h.
Referenced by beginTermination(), publishTerminationReapable(), waitUntilTerminationReapable(), and waitUntilTerminationReapableForTerminalCoordinator().
|
private |
Process::kill has installed the complete live-thread rendezvous.
Definition at line 1177 of file Process.h.
Referenced by beginTermination(), prepareThreadExit(), quiesceTermination(), reserveTerminalOwner(), and terminatingThreadReapable().
|
private |
No further thread may join the rendezvous before publication.
Definition at line 1189 of file Process.h.
Referenced by addThread(), beginTermination(), quiesceTermination(), reserveTerminalOwner(), and terminatingThreadReapable().
|
private |
Whether Process destruction has closed Thread::join admission.
Definition at line 1112 of file Process.h.
Referenced by beginThreadJoin(), and ~Process().
|
private |
Stock kernel processes do not need timer-report worker publications.
Definition at line 1326 of file Process.h.
Referenced by closeDeferredTimeAccounting(), enableTimeAccountingReports(), and setTimeAccountingReportInterest().
|
private |
Scheduler enumeration no longer contains this process.
Definition at line 1161 of file Process.h.
Referenced by prepareForDestruction().
|
private |
|
private |
Waiters for state changes in any direct child of this process.
Definition at line 1094 of file Process.h.
Referenced by beginTermination(), prepareForDestruction(), publish(), publishTerminationStatus(), resume(), and suspendInternal().
|
private |
Invalidates default-stop deliveries which predate a continuation.
Definition at line 1103 of file Process.h.
Referenced by getContinuationEpoch(), resume(), and suspendInternal().
|
private |
|
private |
Pins the Process while an off-stack Thread awaits ordinary destruction.
Definition at line 1323 of file Process.h.
Referenced by ~Process().
|
private |
Lock-free IRQ/scheduler publication consumed by an ordinary worker.
Definition at line 1317 of file Process.h.
Referenced by closeDeferredTimeAccounting(), drainDeferredTimeAccounting(), and setTimeAccountingReportInterest().
|
private |
Memory allocator for dynamic address space, if any.
Definition at line 1058 of file Process.h.
Referenced by commitUserReservations().
|
private |
|
private |
Short predicate lock. Scheduler enumeration may nest this under the global scheduler lock; it is never held while waking lease drainers.
Definition at line 1118 of file Process.h.
Referenced by beginExternalLease(), closeExternalLeaseAdmission(), drainExternalLeases(), and endExternalLease().
|
private |
Lifetime barrier for scheduler enumeration leases.
Definition at line 1121 of file Process.h.
Referenced by drainExternalLeases(), and endExternalLease().
|
private |
|
mutableprivate |
Protects only the owner slots; provider calls run after unlocking.
Definition at line 1044 of file Process.h.
Referenced by installFilesystemContext().
|
private |
Our Process ID.
Definition at line 1020 of file Process.h.
Referenced by addThread(), beginTermination(), endExternalLease(), endThreadJoin(), installTerminalOwner(), kill(), publishTerminationReapable(), publishTerminationStatus(), quiesceTermination(), reap(), reserveTerminalOwner(), terminatingThreadReapable(), transitionToTerminating(), and ~Process().
|
private |
Concurrency lock for complex Process data structures.
Definition at line 1204 of file Process.h.
Referenced by acquireProcessSignalThread(), acquireThread(), acquireThread(), acquireThreadById(), addThread(), beginTermination(), Thread::detach(), Thread::endExternalLease(), getNumThreads(), installTerminalOwner(), Thread::joinInternal(), prepareThreadExit(), publishTerminationReapable(), quiesceTermination(), removeThread(), reserveTerminalOwner(), Thread::startDetached(), and ~Process().
|
private |
Current user.
Definition at line 1078 of file Process.h.
Referenced by setEffectiveUser(), setGroup(), and setUser().
|
private |
Process leases admitted before scheduler removal.
Definition at line 1124 of file Process.h.
Referenced by beginExternalLease(), drainExternalLeases(), and endExternalLease().
|
private |
|
private |
Process-exit participants that have not yet switched off-stack.
Definition at line 1174 of file Process.h.
Referenced by addThread(), beginTermination(), publishTerminationReapable(), quiesceTermination(), and terminatingThreadReapable().
|
private |
Join operations admitted before destruction closed the process.
Definition at line 1109 of file Process.h.
Referenced by beginThreadJoin(), endThreadJoin(), and ~Process().
|
private |
Our virtual address space.
Definition at line 1037 of file Process.h.
Referenced by releaseVforkAddressSpace(), and ~Process().
|
private |
|
private |
|
private |
Effective user.
Definition at line 1083 of file Process.h.
Referenced by getEffectiveUser(), and setEffectiveUser().
|
private |
Latest stop/continue transition not yet selected by a parent wait.
Definition at line 1133 of file Process.h.
Referenced by publishTerminationStatus(), resume(), selectPendingChildTransition(), and suspendInternal().
|
private |
Replacement admission and its irreversible sibling teardown phase.
Definition at line 1167 of file Process.h.
Referenced by acquireProcessSignalThread(), and beginTermination().
|
private |
|
staticprivate |
Init process (terminated processes' children will reparent to this).
Definition at line 1334 of file Process.h.
Referenced by beginTermination(), getInit(), prepareForDestruction(), and setInit().
|
private |
Our parent process.
Definition at line 1033 of file Process.h.
Referenced by beginTermination(), and publish().
|
private |
Installed owner permitted to consume the terminal reservation.
Definition at line 1183 of file Process.h.
Referenced by beginTermination(), installTerminalOwner(), prepareThreadExit(), and reserveTerminalOwner().
|
private |
The subsystem for this process
Definition at line 1091 of file Process.h.
Referenced by removeThread(), threadExiting(), transferExecProcessSignals(), and ~Process().
|
private |
Thread that initiated exit, used to reject self-waiting destruction.
Definition at line 1164 of file Process.h.
Referenced by beginTermination(), publishTerminationReapable(), quiesceTermination(), waitUntilTerminationReapable(), and waitUntilTerminationReapableForTerminalCoordinator().
|
private |
|
private |
One-shot ownership of deferred Process destruction.
Definition at line 1201 of file Process.h.
Referenced by publishReaperClaim(), and tryClaimReaper().
|
private |
Memory allocator for primary address space.
Definition at line 1054 of file Process.h.
Referenced by commitUserReservations().
|
private |
|
private |
Predicate queue for the process stopped/running state.
Definition at line 1100 of file Process.h.
Referenced by getContinuationEpoch(), publishTerminationStatus(), resume(), selectPendingChildTransition(), and suspendInternal().
|
private |
Completion used by deferred Process destruction.
Definition at line 1097 of file Process.h.
Referenced by beginTermination(), publishTerminationReapable(), quiesceTermination(), waitUntilTerminationReapable(), and waitUntilTerminationReapableForTerminalCoordinator().
|
private |
Lifetime barrier for Thread::join operations using this process.
Definition at line 1106 of file Process.h.
Referenced by beginThreadJoin(), endThreadJoin(), and ~Process().
Our list of threads.
Definition at line 1012 of file Process.h.
Referenced by acquireProcessSignalThread(), acquireThread(), acquireThread(), acquireThreadById(), addThread(), beginTermination(), getNumThreads(), installTerminalOwner(), prepareThreadExit(), publishTerminationReapable(), removeThread(), totalTime(), and ~Process().
|
mutableprivate |
Totals may be queried under timer, signal, or child-state locks. Writers take this inside m_Lock only around vector mutation and retired transfer; readers take only this lock and never invoke callbacks while holding it.
Definition at line 1211 of file Process.h.
Referenced by addThread(), removeThread(), totalTime(), and ~Process().
|
private |
Prevents time-report callbacks from crossing process teardown.
Definition at line 1320 of file Process.h.
Referenced by closeDeferredTimeAccounting(), and drainDeferredTimeAccounting().
|
private |
|
private |
Shared userspace PID namespace inherited by child processes.
Definition at line 1022 of file Process.h.
Referenced by addThread(), beginTermination(), and publish().
|
private |
PID assigned within m_UserspaceNamespace; zero for kernel-only processes.
Definition at line 1024 of file Process.h.
Referenced by addThread().
|
private |
|
private |