The Pedigree Project
0.1
|
#include <Thread.h>
Classes | |
struct | StateLevel |
Public Types | |
enum | Status { Ready, Running, Sleeping, Zombie, AwaitingJoin, Suspended } |
enum | DebugState { None, SemWait, CondWait, Joining } |
enum | WakeReason { NotWoken, WokenByAlarm, WokenByEvent, WokenBecauseTerminating, WokenBecauseUnwinding, Unknown } |
enum | UnwindType { Continue = 0, ReleaseBlockingThread, Exit } |
typedef int(* | ThreadStartFunc) (void *) |
Public Member Functions | |
Thread (Process *pParent, ThreadStartFunc pStartFunction, void *pParam, void *pStack=0, bool semiUser=false, bool bDontPickCore=false, bool delayedStart=false) | |
Thread (Process *pParent) | |
Thread (Process *pParent, SyscallState &state, bool delayedStart=false) | |
virtual | ~Thread () |
void | shutdown () |
void | forceToStartupProcessor () |
SchedulerState & | state () |
SchedulerState & | pushState () |
void | popState (bool clean=true) |
VirtualAddressSpace::Stack * | getStateUserStack () |
void | setStateUserStack (VirtualAddressSpace::Stack *st) |
size_t | getStateLevel () const |
void | allocateStackAtLevel (size_t stateLevel) |
void | setKernelStack () |
void | pokeState (size_t stateLevel, SchedulerState &state) |
Process * | getParent () const |
void | setParent (Process *p) |
Status | getStatus () const |
void | setStatus (Status s) |
int | getExitCode () |
void * | getKernelStack () |
size_t | getId () |
size_t | getErrno () |
void | setErrno (size_t err) |
bool | wasInterrupted () |
void | setInterrupted (bool b) |
UnwindType | getUnwindState () |
void | setUnwindState (UnwindType ut) |
void | setBlockingThread (Thread *pT) |
Thread * | getBlockingThread (size_t level=~0UL) |
DebugState | getDebugState (uintptr_t &address) |
void | setDebugState (DebugState state, uintptr_t address) |
Spinlock & | getLock () |
bool | sendEvent (Event *pEvent) |
void | inhibitEvent (size_t eventNumber, bool bInhibit) |
void | cullEvent (Event *pEvent) |
void | cullEvent (size_t eventNumber) |
Event * | getNextEvent () |
bool | hasEvents () |
bool | hasEvent (Event *pEvent) |
bool | hasEvent (size_t eventNumber) |
void | setPriority (size_t p) |
size_t | getPriority () |
void | addRequest (RequestQueue::Request *req) |
void | removeRequest (RequestQueue::Request *req) |
void | unexpectedExit () |
uintptr_t | getTlsBase () |
void | resetTlsBase () |
void | setTlsBase (uintptr_t base) |
size_t | getCpuId () |
void | setCpuId (size_t id) |
bool | join () |
bool | detach () |
bool | detached () const |
bool | isInterruptible () |
void | addWakeupWatcher (WakeReason *watcher) |
void | removeWakeupWatcher (WakeReason *watcher) |
class PerProcessorScheduler * | getScheduler () const |
Static Public Member Functions | |
static void | threadExited () NORETURN |
Protected Member Functions | |
void | setScheduler (class PerProcessorScheduler *pScheduler) |
void | setInterruptible (bool state) |
Private Member Functions | |
Thread (const Thread &) | |
Thread & | operator= (const Thread &) |
void | cleanStateLevel (size_t level) |
void | reportWakeup (WakeReason reason) |
void | reportWakeupUnlocked (WakeReason reason) |
Private Attributes | |
size_t | m_nStateLevel = 0 |
Process * | m_pParent = nullptr |
void * | m_pAllocatedStack = nullptr |
size_t | m_Id = 0 |
size_t | m_Errno = 0 |
uintptr_t | m_DebugStateAddress = 0 |
class PerProcessorScheduler * | m_pScheduler = nullptr |
size_t | m_Priority = DEFAULT_PRIORITY |
void * | m_pTlsBase = nullptr |
size_t | m_ProcId = 0 |
Thread * | m_pWaiter = nullptr |
Spinlock | m_Lock |
Spinlock | m_ConcurrencyLock |
List< Event * > | m_EventQueue |
List< RequestQueue::Request * > | m_PendingRequests |
List< WakeReason * > | m_WakeWatchers |
StateLevel | m_StateLevels [MAX_NESTED_EVENTS] |
volatile Status | m_Status = Ready |
int | m_ExitCode = 0 |
DebugState | m_DebugState = None |
UnwindType | m_UnwindState = Continue |
bool | m_bInterrupted = false |
bool | m_bTlsBaseOverride = false |
bool | m_bRemovingRequests = false |
bool | m_bDetached = false |
bool | m_bInterruptible = true |
Friends | |
class | PerProcessorScheduler |
class | Uninterruptible |
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 |
enum Thread::WakeReason |
Thread::Thread | ( | Process * | pParent, |
ThreadStartFunc | pStartFunction, | ||
void * | pParam, | ||
void * | pStack = 0 , |
||
bool | semiUser = false , |
||
bool | bDontPickCore = false , |
||
bool | delayedStart = false |
||
) |
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 42 of file Thread.cc.
References Spinlock::acquire(), ProcessorThreadAllocator::addThread(), Scheduler::addThread(), Process::addThread(), allocateStackAtLevel(), FATAL, getScheduler(), Processor::information(), Scheduler::instance(), m_Id, m_Lock, m_pAllocatedStack, Thread::StateLevel::m_pAuxillaryStack, Thread::StateLevel::m_pKernelStack, m_pParent, and m_Status.
Thread::Thread | ( | Process * | pParent | ) |
Alternative constructor - this should be used only by initialiseMultitasking() to define the first kernel thread.
Definition at line 116 of file Thread.cc.
References Scheduler::addThread(), Process::addThread(), FATAL, Scheduler::instance(), m_Id, and m_pParent.
Thread::Thread | ( | Process * | pParent, |
SyscallState & | state, | ||
bool | delayedStart = false |
||
) |
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 135 of file Thread.cc.
References Spinlock::acquire(), ProcessorThreadAllocator::addThread(), Process::addThread(), allocateStackAtLevel(), FATAL, Processor::information(), m_bTlsBaseOverride, m_Id, m_Lock, m_pAllocatedStack, m_pParent, m_pTlsBase, and m_Status.
|
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 175 of file Thread.cc.
References Spinlock::acquire(), cleanStateLevel(), ERROR, RangeList< T, Reversed >::free(), PhysicalMemoryManager::freePage(), Process::getAddressSpace(), Process::getDynamicSpaceAllocator(), VirtualAddressSpace::getDynamicStart(), VirtualAddressSpace::getMapping(), Process::getSpaceAllocator(), NMFaultHandler::instance(), Scheduler::instance(), PhysicalMemoryManager::instance(), InputManager::instance(), VirtualAddressSpace::isMapped(), m_bRemovingRequests, m_bTlsBaseOverride, Process::m_Lock, m_pParent, m_pTlsBase, Spinlock::release(), Scheduler::removeThread(), Process::removeThread(), shutdown(), VirtualAddressSpace::unmap(), and WARNING.
|
private |
Copy-constructor
void Thread::addRequest | ( | RequestQueue::Request * | req | ) |
Adds a request to the Thread's pending request list
Definition at line 730 of file Thread.cc.
References m_bRemovingRequests, m_PendingRequests, and List< T, nodePoolSize >::pushBack().
Referenced by RequestQueue::addRequest().
void Thread::addWakeupWatcher | ( | WakeReason * | watcher | ) |
Add a new watcher location that is updated when this thread is woken.
Definition at line 988 of file Thread.cc.
References m_Lock, m_WakeWatchers, and List< T, nodePoolSize >::pushBack().
Referenced by Semaphore::acquireWithResult().
void Thread::allocateStackAtLevel | ( | size_t | stateLevel | ) |
Allocates a new stack for a specific nesting level, if required
Definition at line 484 of file Thread.cc.
References VirtualAddressSpace::allocateStack(), VirtualAddressSpace::getKernelAddressSpace(), and Thread::StateLevel::m_pKernelStack.
Referenced by pushState(), and Thread().
|
private |
Cleans up the given state level.
Definition at line 961 of file Thread.cc.
References VirtualAddressSpace::freeStack(), Process::getAddressSpace(), VirtualAddressSpace::getKernelAddressSpace(), Thread::StateLevel::m_InhibitMask, Thread::StateLevel::m_pAuxillaryStack, Thread::StateLevel::m_pKernelStack, m_pParent, and SharedPointer< T >::reset().
Referenced by popState(), and ~Thread().
void Thread::cullEvent | ( | Event * | pEvent | ) |
Walks the event queue, removing the event pEvent
, if found.
Definition at line 580 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 613 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().
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 885 of file Thread.cc.
References SharedPointer< T >::allocate(), ERROR, join(), m_bDetached, m_ConcurrencyLock, Thread::StateLevel::m_InhibitMask, Thread::StateLevel::m_pAuxillaryStack, Thread::StateLevel::m_pKernelStack, m_pWaiter, Thread::StateLevel::m_State, m_Status, and WARNING.
Referenced by RequestQueue::addAsyncRequest(), KernelElf::getDependingModule(), Ps2Mouse::initialise(), PerProcessorScheduler::initialise(), Dm9601::initialiseDriver(), PosixSubsystem::invoke(), Ehci::irq(), Ne2k::Ne2k(), Nic3C90x::Nic3C90x(), pocketknife::runConcurrently(), and X86Keyboard::setLedState().
|
inline |
Checks detached state of the thread.
Definition at line 417 of file Thread.h.
References NORETURN, and PerProcessorScheduler::operator=().
Referenced by PerProcessorScheduler::killCurrentThread(), and Process::~Process().
|
inline |
Gets this thread's CPU ID
Definition at line 378 of file Thread.h.
Referenced by ThreadsCommand::execute().
|
inline |
Returns the thread's debug state.
Definition at line 288 of file Thread.h.
Referenced by ThreadsCommand::execute().
|
inline |
|
inline |
|
inline |
Returns the Thread's ID.
Definition at line 210 of file Thread.h.
Referenced by PerProcessorScheduler::checkEventState(), ThreadsCommand::execute(), X64InterruptManager::interrupt(), PosixSubsystem::sendSignal(), and PosixSubsystem::threadException().
void * Thread::getKernelStack | ( | ) |
Retrieves a pointer to the top of the Thread's kernel stack.
Definition at line 493 of file Thread.cc.
References FATAL, m_nStateLevel, and Thread::StateLevel::m_pKernelStack.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::initialise(), PerProcessorScheduler::killCurrentThread(), and PerProcessorScheduler::schedule().
|
inline |
Returns the thread's scheduler lock.
Definition at line 301 of file Thread.h.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::killCurrentThread(), Semaphore::release(), PerProcessorScheduler::schedule(), shutdown(), and ConditionVariable::signal().
Event * Thread::getNextEvent | ( | ) |
Grabs the first available unmasked event and pops it off the queue. This also pushes the inhibit mask stack.
Definition at line 643 of file Thread.cc.
References List< T, nodePoolSize >::count(), Event::deregisterThread(), ERROR, Event::getNumber(), Event::getSpecificNestingLevel(), m_bInterruptible, m_EventQueue, m_Lock, m_nStateLevel, List< T, nodePoolSize >::popFront(), and List< T, nodePoolSize >::pushBack().
Referenced by PerProcessorScheduler::checkEventState().
|
inline |
Retrieves a pointer to this Thread's parent process.
Definition at line 181 of file Thread.h.
Referenced by PerProcessorScheduler::addThread(), SlamAllocator::allocate(), PerProcessorScheduler::checkEventState(), PosixSubsystem::exit(), PerProcessorScheduler::initialise(), X64InterruptManager::interrupt(), HostedInterruptManager::interrupt(), X86InterruptManager::interrupt(), PosixSubsystem::kill(), PerProcessorScheduler::killCurrentThread(), PerProcessorScheduler::schedule(), PosixSubsystem::sendSignal(), X86CommonProcessorInformation::setTlsSelector(), PosixSubsystem::threadException(), and PerProcessorScheduler::timer().
PerProcessorScheduler * Thread::getScheduler | ( | ) | const |
Gets the per-processor scheduler for this Thread.
Definition at line 956 of file Thread.cc.
Referenced by PerProcessorScheduler::checkEventState(), PerProcessorScheduler::schedule(), and Thread().
size_t Thread::getStateLevel | ( | ) | const |
Returns the state nesting level.
Definition at line 474 of file Thread.cc.
References m_nStateLevel.
Referenced by PerProcessorScheduler::checkEventState(), PosixSubsystem::exit(), PosixSubsystem::invoke(), PerProcessorScheduler::schedule(), and TimeoutGuard::TimeoutGuard().
|
inline |
Retrieves our current status.
Definition at line 192 of file Thread.h.
Referenced by PerProcessorScheduler::addThread(), ThreadsCommand::execute(), Process::kill(), PerProcessorScheduler::processorAddThread(), Semaphore::release(), WaitCleanup::terminated(), and RoundRobin::threadStatusChanged().
uintptr_t Thread::getTlsBase | ( | ) |
Gets the TLS base address for this thread.
Definition at line 758 of file Thread.cc.
References RangeList< T, Reversed >::allocate(), PhysicalMemoryManager::allocatePage(), Dec, Process::getAddressSpace(), Process::getDynamicSpaceAllocator(), VirtualAddressSpace::getDynamicStart(), Process::getId(), Process::getSpaceAllocator(), Hex, PhysicalMemoryManager::instance(), m_Id, m_pParent, m_pTlsBase, VirtualAddressSpace::map(), NOTICE, and VirtualAddressSpace::Write.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::initialise(), PerProcessorScheduler::killCurrentThread(), resetTlsBase(), PerProcessorScheduler::schedule(), and setTlsBase().
|
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 261 of file Thread.h.
Referenced by RequestQueue::addRequest(), join(), PerProcessorScheduler::timer(), and ConditionVariable::wait().
bool Thread::hasEvent | ( | Event * | pEvent | ) |
Determines if the given event is currently in the event queue.
Definition at line 698 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), m_EventQueue, and m_Lock.
Referenced by PosixSubsystem::sendSignal().
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 571 of file Thread.cc.
References ExtensibleBitmap::clear(), Thread::StateLevel::m_InhibitMask, m_Lock, m_nStateLevel, and ExtensibleBitmap::set().
bool Thread::isInterruptible | ( | ) |
Gets whether this thread is interruptible or not.
Definition at line 940 of file Thread.cc.
References m_bInterruptible.
Referenced by PerProcessorScheduler::checkEventState().
bool Thread::join | ( | ) |
Blocks until the Thread returns.
After join() returns successfully, the thread object is NOT valid.
Definition at line 836 of file Thread.cc.
References Spinlock::acquire(), Continue, getUnwindState(), Processor::information(), m_bDetached, m_ConcurrencyLock, m_pWaiter, m_Status, Spinlock::release(), setDebugState(), and wasInterrupted().
Referenced by pocketknife::attachTo(), detach(), RequestQueue::halt(), and InputManager::shutdown().
Assignment operator
Referenced by Process::hasSharedAddressSpace().
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 517 of file Thread.cc.
References ERROR, and Thread::StateLevel::m_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 444 of file Thread.cc.
References cleanStateLevel(), ERROR, m_nStateLevel, and setKernelStack().
Referenced by PerProcessorScheduler::checkEventState(), PerProcessorScheduler::eventHandlerReturned(), and PosixSubsystem::invoke().
SchedulerState & Thread::pushState | ( | ) |
Increases the state nesting level by one - pushes a new state to the top of the state stack. This also pushes to the top of the inhibited events stack, copying the current inhibit mask.
Definition at line 425 of file Thread.cc.
References allocateStackAtLevel(), ERROR, Thread::StateLevel::m_InhibitMask, m_nStateLevel, Thread::StateLevel::m_State, and setKernelStack().
Referenced by PerProcessorScheduler::checkEventState().
void Thread::removeRequest | ( | RequestQueue::Request * | req | ) |
Removes a request from the Thread's pending request list
Definition at line 738 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), List< T, nodePoolSize >::erase(), m_bRemovingRequests, and m_PendingRequests.
Referenced by RequestQueue::addRequest(), and RequestQueue::work().
void Thread::removeWakeupWatcher | ( | WakeReason * | watcher | ) |
Remove a wakeup watcher.
Definition at line 995 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), List< T, nodePoolSize >::erase(), m_Lock, and m_WakeWatchers.
Referenced by Semaphore::acquireWithResult().
|
private |
Report a wakeup.
Definition at line 1012 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::clear(), List< T, nodePoolSize >::end(), m_Lock, and m_WakeWatchers.
Referenced by sendEvent(), and shutdown().
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 811 of file Thread.cc.
References getTlsBase(), m_bTlsBaseOverride, m_pTlsBase, and Processor::setTlsBase().
Referenced by PosixSubsystem::invoke().
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.
Definition at line 529 of file Thread.cc.
References Spinlock::acquire(), Scheduler::instance(), m_bInterruptible, m_EventQueue, m_Lock, m_Status, List< T, nodePoolSize >::pushBack(), Event::registerThread(), Spinlock::release(), reportWakeup(), and WARNING.
Referenced by PerProcessorScheduler::checkEventState(), File::dataChanged(), GPTimer::interrupt(), HostedTimer::irq(), Rtc::irq(), PosixSubsystem::kill(), InputManager::mainThread(), Buffer< T, allowShortOperation >::notifyMonitors(), PosixSubsystem::sendSignal(), and ConsoleFile::triggerEvent().
|
inline |
Sets this thread's CPU ID
Definition at line 384 of file Thread.h.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::initialise(), and PerProcessorScheduler::processorAddThread().
|
inline |
Sets the thread's debug state.
Definition at line 294 of file Thread.h.
Referenced by Semaphore::acquireWithResult(), join(), and ConditionVariable::wait().
|
inline |
|
inline |
Sets whether the thread was just interrupted deliberately.
Definition at line 235 of file Thread.h.
Referenced by Semaphore::acquireWithResult(), and ConditionVariable::wait().
|
protected |
void Thread::setKernelStack | ( | ) |
Sets the new kernel stack for the current state level in the TSS
Definition at line 507 of file Thread.cc.
References Processor::information(), m_nStateLevel, and Thread::StateLevel::m_pKernelStack.
Referenced by popState(), and pushState().
|
protected |
Sets the scheduler for the Thread.
Definition at line 951 of file Thread.cc.
Referenced by PerProcessorScheduler::addThread().
void Thread::setStatus | ( | Thread::Status | s | ) |
Sets our current status.
Definition at line 364 of file Thread.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::clear(), List< T, nodePoolSize >::end(), FATAL, Process::getId(), Event::isDeletable(), m_EventQueue, m_pParent, m_Status, Process::notifyWaiters(), and WARNING.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::initialise(), PerProcessorScheduler::killCurrentThread(), Semaphore::release(), PerProcessorScheduler::schedule(), shutdown(), ConditionVariable::signal(), and Process::~Process().
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.
Definition at line 818 of file Thread.cc.
References getTlsBase(), Processor::information(), m_bTlsBaseOverride, m_pTlsBase, and Processor::setTlsBase().
|
inline |
Sets the above unwind state.
Definition at line 266 of file Thread.h.
Referenced by Semaphore::acquireWithResult(), and PosixSubsystem::exit().
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 234 of file Thread.cc.
References Spinlock::acquire(), Scheduler::addThread(), List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::count(), List< T, nodePoolSize >::end(), List< T, nodePoolSize >::erase(), ERROR, getLock(), RequestQueue::halt(), Processor::information(), Scheduler::instance(), RequestQueue::isRequestValid(), m_bDetached, m_bRemovingRequests, m_ConcurrencyLock, m_PendingRequests, m_pWaiter, m_Status, Spinlock::release(), Semaphore::release(), Scheduler::removeThread(), reportWakeup(), RequestQueue::resume(), setStatus(), and Scheduler::yield().
Referenced by PerProcessorScheduler::killCurrentThread(), Process::~Process(), and ~Thread().
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 420 of file Thread.cc.
References m_nStateLevel, and Thread::StateLevel::m_State.
Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::eventHandlerReturned(), NMFaultHandler::interrupt(), PosixSubsystem::invoke(), PerProcessorScheduler::killCurrentThread(), NMFaultHandler::NMFaultHandler(), PerProcessorScheduler::schedule(), and setInterruptible().
|
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 479 of file Thread.cc.
References Processor::information().
void Thread::unexpectedExit | ( | ) |
An unexpected exit has occurred, perform cleanup
Definition at line 754 of file Thread.cc.
Referenced by PosixSubsystem::exit().
|
inline |
Returns whether the thread was just interrupted deliberately (e.g. because of a timeout).
Definition at line 229 of file Thread.h.
Referenced by Semaphore::acquireWithResult(), RequestQueue::addRequest(), join(), and ConditionVariable::wait().
|
private |
Whether this thread has been detached or not.
Definition at line 577 of file Thread.h.
Referenced by detach(), join(), and shutdown().
|
private |
Whether the thread was interrupted deliberately.
|
private |
Whether this thread has been marked interruptible or not.
Definition at line 580 of file Thread.h.
Referenced by getNextEvent(), isInterruptible(), sendEvent(), and setInterruptible().
|
private |
Are we in the process of removing tracked RequestQueue::Request objects?
Definition at line 574 of file Thread.h.
Referenced by addRequest(), removeRequest(), shutdown(), and ~Thread().
|
private |
Whether or not userspace has overridden its TLS base.
Definition at line 570 of file Thread.h.
Referenced by resetTlsBase(), setTlsBase(), Thread(), and ~Thread().
|
private |
General concurrency lock, not touched by schedulers.
Definition at line 540 of file Thread.h.
Referenced by detach(), join(), and shutdown().
|
private |
|
private |
|
private |
Queue of Events ready to run.
Definition at line 543 of file Thread.h.
Referenced by cullEvent(), getNextEvent(), hasEvent(), sendEvent(), and setStatus().
|
private |
Our thread ID.
Definition at line 510 of file Thread.h.
Referenced by Process::getId(), getTlsBase(), and Thread().
|
private |
Lock for schedulers.
Definition at line 537 of file Thread.h.
Referenced by PerProcessorScheduler::addThread(), addWakeupWatcher(), cullEvent(), getNextEvent(), hasEvent(), inhibitEvent(), PerProcessorScheduler::processorAddThread(), removeWakeupWatcher(), reportWakeup(), sendEvent(), setInterruptible(), and Thread().
|
private |
The current index into m_States (head of the state stack).
Definition at line 499 of file Thread.h.
Referenced by getKernelStack(), getNextEvent(), getStateLevel(), inhibitEvent(), popState(), pushState(), setKernelStack(), and state().
|
private |
|
private |
List of requests pending on this Thread
Definition at line 546 of file Thread.h.
Referenced by addRequest(), removeRequest(), and shutdown().
|
private |
Our parent process.
Definition at line 502 of file Thread.h.
Referenced by cleanStateLevel(), Process::getParent(), getTlsBase(), setStatus(), Thread(), and ~Thread().
|
private |
|
private |
Memory mapping for the TLS base of this thread (userspace-only)
Definition at line 524 of file Thread.h.
Referenced by getTlsBase(), resetTlsBase(), setTlsBase(), Thread(), and ~Thread().
|
private |
Waiters on this thread.
Definition at line 534 of file Thread.h.
Referenced by detach(), join(), and shutdown().
|
private |
Our current status.
Definition at line 554 of file Thread.h.
Referenced by detach(), join(), sendEvent(), setStatus(), shutdown(), and Thread().
|
private |
List of wakeup watchers that need to be informed when we wake up.
Definition at line 549 of file Thread.h.
Referenced by addWakeupWatcher(), removeWakeupWatcher(), and reportWakeup().