The Pedigree Project
0.1
|
This class manages how processes and threads are scheduled across processors. More...
#include <Scheduler.h>
Public Member Functions | |
bool | initialise (Process *pKernelProcess) |
void | addThread (Thread *pThread, PerProcessorScheduler &PPSched) |
void | removeThread (Thread *pThread) |
bool | threadInSchedule (Thread *pThread) |
size_t | addProcess (Process *pProcess) |
void | removeProcess (Process *pProcess) |
void | yield () |
size_t | getNumProcesses () |
Process * | getProcess (size_t n) |
void | threadStatusChanged (Thread *pThread) |
Process * | getKernelProcess () const |
PerProcessorScheduler * | getBootstrapProcessorScheduler () const |
Static Public Member Functions | |
static Scheduler & | instance () |
Private Member Functions | |
NOT_COPYABLE_OR_ASSIGNABLE (Scheduler) | |
Private Attributes | |
List< Process *, 0 > | m_Processes |
Atomic< size_t > | m_NextPid |
Tree< PerProcessorScheduler *, List< Thread * > * > | m_PTMap |
Tree< Thread *, PerProcessorScheduler * > | m_TPMap |
Process * | m_pKernelProcess |
PerProcessorScheduler * | m_pBspScheduler |
Spinlock | m_SchedulerLock |
Static Private Attributes | |
static Scheduler | m_Instance |
This class manages how processes and threads are scheduled across processors.
This is the "long term" scheduler - it load balances between processors and provides the interface for adding, listing and removing threads.
The load balancing is "lazy" in that the algorithm only runs on thread addition and removal.
Definition at line 44 of file Scheduler.h.
size_t Scheduler::addProcess | ( | Process * | pProcess | ) |
Adds a process.
Definition at line 109 of file Scheduler.cc.
Referenced by Process::Process().
void Scheduler::addThread | ( | Thread * | pThread, |
PerProcessorScheduler & | PPSched | ||
) |
Adds a thread to be load-balanced and accounted.
pThread | The new thread. |
PPSched | The per-processor scheduler the thread will start on. |
Definition at line 79 of file Scheduler.cc.
Referenced by ProcessorThreadAllocator::addThread(), Thread::shutdown(), and Thread::Thread().
size_t Scheduler::getNumProcesses | ( | ) |
Returns the number of processes currently in operation.
Definition at line 140 of file Scheduler.cc.
Referenced by MemoryPressureProcessKiller::compact(), ThreadsCommand::execute(), Rtc::irq(), Process::kill(), X64VirtualAddressSpace::mapUnlocked(), WaitCleanup::terminated(), and X86VirtualAddressSpace::X86VirtualAddressSpace().
Process * Scheduler::getProcess | ( | size_t | n | ) |
Returns the n'th process currently in operation.
Definition at line 149 of file Scheduler.cc.
References assert, List< T, nodePoolSize >::begin(), Dec, and WARNING.
Referenced by MemoryPressureProcessKiller::compact(), ThreadsCommand::execute(), Rtc::irq(), Process::kill(), X64VirtualAddressSpace::mapUnlocked(), WaitCleanup::terminated(), and X86VirtualAddressSpace::X86VirtualAddressSpace().
bool Scheduler::initialise | ( | Process * | pKernelProcess | ) |
Initialises the scheduler.
Definition at line 51 of file Scheduler.cc.
References Processor::information(), Processor::m_ProcessorInformation, List< T, nodePoolSize >::pushBack(), and ProcessorThreadAllocator::setAlgorithm().
|
inlinestatic |
Get the instance of the scheduler
Definition at line 48 of file Scheduler.h.
Referenced by RequestQueue::addAsyncRequest(), ProcessorThreadAllocator::addThread(), MemoryPressureProcessKiller::compact(), File::dataChanged(), ThreadsCommand::execute(), CacheManager::executeRequest(), FatFilesystem::getClusterEntry(), RequestQueue::initialise(), Rtc::irq(), Process::kill(), PosixSubsystem::kill(), InputManager::mainThread(), X64VirtualAddressSpace::mapUnlocked(), Process::Process(), LwipSocketSyscalls::recvfrom_msg(), Semaphore::release(), Thread::sendEvent(), PosixSubsystem::sendSignal(), Thread::shutdown(), PosixSyscallManager::syscall(), KernelCoreSyscallManager::syscall(), WaitCleanup::terminated(), Thread::Thread(), ConsoleFile::triggerEvent(), Event::waitForDeliveries(), X86VirtualAddressSpace::X86VirtualAddressSpace(), Process::~Process(), and Thread::~Thread().
void Scheduler::removeProcess | ( | Process * | pProcess | ) |
Removes a process.
Definition at line 119 of file Scheduler.cc.
References List< T, nodePoolSize >::begin().
Referenced by WaitCleanup::terminated(), and Process::~Process().
void Scheduler::removeThread | ( | Thread * | pThread | ) |
Removes a thread from being load-balanced and accounted.
Definition at line 87 of file Scheduler.cc.
Referenced by Thread::shutdown(), and Thread::~Thread().
bool Scheduler::threadInSchedule | ( | Thread * | pThread | ) |
Whether a thread is entered into the scheduler at all.
Definition at line 100 of file Scheduler.cc.
void Scheduler::yield | ( | ) |
Causes a manual reschedule.
Definition at line 135 of file Scheduler.cc.
References Processor::information().
Referenced by MemoryPressureProcessKiller::compact(), File::dataChanged(), CacheManager::executeRequest(), FatFilesystem::getClusterEntry(), PosixSubsystem::kill(), InputManager::mainThread(), LwipSocketSyscalls::recvfrom_msg(), PosixSubsystem::sendSignal(), Thread::shutdown(), PosixSyscallManager::syscall(), KernelCoreSyscallManager::syscall(), WaitCleanup::terminated(), ConsoleFile::triggerEvent(), and Event::waitForDeliveries().
|
staticprivate |
The Scheduler instance.
Definition at line 104 of file Scheduler.h.
|
private |
The next available process ID.
Definition at line 111 of file Scheduler.h.
|
private |
Pointer to the BSP's scheduler.
This may be necessary for threads that need to depend on e.g. interrupts that are only coming to the BSP, and having them run on a different CPU means they cannot control things like IRQs being enabled (not good).
Definition at line 129 of file Scheduler.h.
|
private |
Pointer to the kernel process.
Definition at line 120 of file Scheduler.h.
All the processes currently in operation, for enumeration purposes.
Definition at line 108 of file Scheduler.h.
|
private |
Map of processor->thread mappings, for load-balance accounting.
Definition at line 114 of file Scheduler.h.
|
private |
Main scheduler lock for modifying internal structures.
Definition at line 132 of file Scheduler.h.
|
private |
Map of thread->processor mappings.
Definition at line 117 of file Scheduler.h.