The Pedigree Project  0.1
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
PerProcessorScheduler Class Reference
+ Inheritance diagram for PerProcessorScheduler:
+ Collaboration diagram for PerProcessorScheduler:

Public Member Functions

 PerProcessorScheduler ()
 
void initialise (Thread *pThread)
 
void schedule (Thread::Status nextStatus=Thread::Ready, Thread *pNewThread=0, Spinlock *pLock=0)
 
void checkEventState (uintptr_t userStack)
 
void eventHandlerReturned () NORETURN
 
void addThread (Thread *pThread, Thread::ThreadStartFunc pStartFunction, void *pParam, bool bUsermode, void *pStack)
 
void addThread (Thread *pThread, SyscallState &state)
 
void killCurrentThread (Spinlock *pLock=0) NORETURN
 
void sleep (Spinlock *pLock=0)
 
void timer (uint64_t delta, InterruptState &state)
 
void removeThread (Thread *pThread)
 
void threadStatusChanged (Thread *pThread)
 
void setIdle (Thread *pThread)
 

Private Member Functions

 PerProcessorScheduler (const PerProcessorScheduler &)
 
PerProcessorScheduleroperator= (const PerProcessorScheduler &)
 

Static Private Member Functions

static void deleteThreadThenRestoreState (Thread *pThread, SchedulerState &newState, volatile uintptr_t *pLock=0) NORETURN
 
static void deleteThread (Thread *pThread)
 
static int processorAddThread (void *instance) NORETURN
 

Private Attributes

SchedulingAlgorithmm_pSchedulingAlgorithm
 
Mutex m_NewThreadDataLock
 
ConditionVariable m_NewThreadDataCondition
 
List< void * > m_NewThreadData
 
Threadm_pIdleThread
 

Detailed Description

Definition at line 37 of file PerProcessorScheduler.h.

Constructor & Destructor Documentation

PerProcessorScheduler::PerProcessorScheduler ( )

Default constructor - Creates an empty scheduler with a new idle thread.

Definition at line 46 of file PerProcessorScheduler.cc.

PerProcessorScheduler::PerProcessorScheduler ( const PerProcessorScheduler )
private

Copy-constructor

Note
Not implemented - singleton class.

Member Function Documentation

void PerProcessorScheduler::addThread ( Thread pThread,
Thread::ThreadStartFunc  pStartFunction,
void *  pParam,
bool  bUsermode,
void *  pStack 
)
void PerProcessorScheduler::addThread ( Thread pThread,
SyscallState &  state 
)
void PerProcessorScheduler::checkEventState ( uintptr_t  userStack)

Looks for event handlers to run, and if found, dispatches one.

Parameters
userStackThe stack to use if the event has a user-mode handler. Usually obtained from an interruptState or syscallState.
Todo:
This is a quickfix for a bigger problem. I imagine it has something to do with calling execve directly without fork, meaning the memory is cleaned up but the state level stack information is not.

Definition at line 310 of file PerProcessorScheduler.cc.

References PhysicalMemoryManager::allocatePage(), VirtualAddressSpace::allocateStack(), Event::getHandlerAddress(), Event::getHandlerBuffer(), Thread::getId(), Processor::getInterrupts(), VirtualAddressSpace::getMapping(), Thread::getNextEvent(), PhysicalMemoryManager::getPageSize(), Thread::getParent(), Thread::getScheduler(), Thread::getStateLevel(), Event::getTrampoline(), Processor::information(), PhysicalMemoryManager::instance(), Event::isDeletable(), Thread::isInterruptible(), VirtualAddressSpace::isMapped(), Processor::jumpUser(), VirtualAddressSpace::KernelMode, VirtualAddressSpace::map(), panic(), Thread::popState(), Thread::pushState(), Process::recordTime(), Processor::saveState(), Thread::sendEvent(), Event::serialize(), Processor::setInterrupts(), Process::trackTime(), and VirtualAddressSpace::Write.

Referenced by schedule(), and sleep().

+ Here is the caller graph for this function:

static void PerProcessorScheduler::deleteThreadThenRestoreState ( Thread pThread,
SchedulerState &  newState,
volatile uintptr_t *  pLock = 0 
)
staticprivate

Switches stacks, calls PerProcessorScheduler::deleteThread, then context switches.

Note
Implemented in core/processor/ARCH/asm

Referenced by killCurrentThread().

+ Here is the caller graph for this function:

void PerProcessorScheduler::eventHandlerReturned ( )

Assumes this thread has just returned from executing a event handler, and lets it resume normal execution.

Definition at line 468 of file PerProcessorScheduler.cc.

References Processor::information(), Thread::popState(), Processor::restoreState(), Processor::setInterrupts(), and Thread::state().

void PerProcessorScheduler::initialise ( Thread pThread)
void PerProcessorScheduler::killCurrentThread ( Spinlock pLock = 0)
PerProcessorScheduler& PerProcessorScheduler::operator= ( const PerProcessorScheduler )
private

Assignment operator

Note
Not implemented - singleton class

Referenced by Thread::detached().

+ Here is the caller graph for this function:

int PerProcessorScheduler::processorAddThread ( void *  instance)
staticprivate
void PerProcessorScheduler::schedule ( Thread::Status  nextStatus = Thread::Ready,
Thread pNewThread = 0,
Spinlock pLock = 0 
)
void PerProcessorScheduler::sleep ( Spinlock pLock = 0)

Puts a thread to sleep.

Parameters
pLockOptional, will release this lock when the thread is successfully in the sleep state.
Note
This function is here because it acts on the current thread. Its counterpart, wake(), is in Scheduler as it could be called from any thread.

Definition at line 787 of file PerProcessorScheduler.cc.

References checkEventState(), Processor::information(), Spinlock::release(), and schedule().

void PerProcessorScheduler::timer ( uint64_t  delta,
InterruptState &  state 
)
virtual

Member Data Documentation

SchedulingAlgorithm* PerProcessorScheduler::m_pSchedulingAlgorithm
private

The current SchedulingAlgorithm

Definition at line 122 of file PerProcessorScheduler.h.

Referenced by addThread(), initialise(), killCurrentThread(), schedule(), and timer().


The documentation for this class was generated from the following files: