FreeNOS
|
Represents a process which may run on the host. More...
#include <ProcessManager.h>
Public Types | |
enum | Result { Success, InvalidArgument, IOError, WakeupPending, AlreadyExists } |
Result code. More... | |
Public Member Functions | |
ProcessManager () | |
Constructor function. More... | |
virtual | ~ProcessManager () |
Destructor function. More... | |
Process * | create (const Address entry, const MemoryMap &map, const bool readyToRun=false, const bool privileged=false) |
Create a new Process. More... | |
Process * | get (const ProcessID id) |
Retrieve a Process by it's ID. More... | |
void | remove (Process *proc, const uint exitStatus=0) |
Remove a Process. More... | |
Result | schedule () |
Schedule next process to run. More... | |
Result | wait (Process *proc) |
Let current Process wait for another Process to terminate. More... | |
Result | stop (Process *proc) |
Remove given Process from the Scheduler. More... | |
Result | resume (Process *proc) |
Resume scheduling of the given Process. More... | |
Result | reset (Process *proc, const Address entry) |
Restart execution of a Process at the given entry point. More... | |
Result | sleep (const Timer::Info *timer=0, const bool ignoreWakeups=false) |
Let current Process sleep until a timer expires or wakeup occurs. More... | |
Result | wakeup (Process *proc) |
Take Process out of Sleep state and mark ready for execution. More... | |
Result | raiseEvent (Process *proc, const struct ProcessEvent *event) |
Raise kernel event for a Process. More... | |
Result | registerInterruptNotify (Process *proc, const u32 vector) |
Register an interrupt notification for a Process. More... | |
Result | unregisterInterruptNotify (Process *proc) |
Remove all interrupt notifications for a Process. More... | |
Result | interruptNotify (const u32 vector) |
Raise interrupt notifications for a interrupt vector. More... | |
void | setIdle (Process *proc) |
Set the idle process. More... | |
Process * | current () |
Current process running. More... | |
Private Member Functions | |
Result | enqueueProcess (Process *proc, const bool ignoreState=false) |
Place the given process on the Schedule queue. More... | |
Result | dequeueProcess (Process *proc, const bool ignoreState=false) const |
Remove the given process on the Schedule queue. More... | |
Private Attributes | |
Index< Process, MAX_PROCS > | m_procs |
All known Processes. More... | |
Scheduler * | m_scheduler |
Object which selects processes to run. More... | |
Process * | m_current |
Currently executing process. More... | |
Process * | m_idle |
Idle process. More... | |
Queue< Process *, MAX_PROCS > | m_sleepTimerQueue |
Queue with sleeping processes waiting for a Timer to expire. More... | |
Vector< List< Process * > * > | m_interruptNotifyList |
Interrupt notification list. More... | |
Represents a process which may run on the host.
Definition at line 44 of file ProcessManager.h.
Result code.
Enumerator | |
---|---|
Success | |
InvalidArgument | |
IOError | |
WakeupPending | |
AlreadyExists |
Definition at line 51 of file ProcessManager.h.
ProcessManager::ProcessManager | ( | ) |
Constructor function.
Definition at line 25 of file ProcessManager.cpp.
References DEBUG, Sequence< T >::fill(), m_current, m_idle, m_interruptNotifyList, m_scheduler, MAX_PROCS, and ZERO.
|
virtual |
Destructor function.
Definition at line 37 of file ProcessManager.cpp.
References m_scheduler, and NULL.
Process * ProcessManager::create | ( | const Address | entry, |
const MemoryMap & | map, | ||
const bool | readyToRun = false , |
||
const bool | privileged = false |
||
) |
Create a new Process.
entry | Process executable entry point |
map | Memory mapping |
readyToRun | True to immediately run the Process or false to sleep. |
privileged | True to create a privileged Process |
Definition at line 45 of file ProcessManager.cpp.
References entry, ERROR, Process::getID(), Process::initialize(), Index< T, N >::insert(), Index< T, N >::insertAt(), m_current, m_procs, Index< T, N >::remove(), resume(), Process::setParent(), Process::Success, and ZERO.
Referenced by Kernel::loadBootProgram(), and ProcessCtlHandler().
Process * ProcessManager::current | ( | ) |
Current process running.
NULL if no process running yet.
Definition at line 203 of file ProcessManager.cpp.
References m_current.
Referenced by ARMKernel::dataAbort(), IntelKernel::exception(), Kernel::getMemoryContext(), SunxiKernel::interrupt(), ARMKernel::interrupt(), RaspberryKernel::interrupt(), ARMKernel::prefetchAbort(), PrivExecHandler(), ProcessCtlHandler(), ARMKernel::reserved(), ARMKernel::trap(), ARMKernel::undefinedInstruction(), VMCopyHandler(), VMCtlHandler(), and VMShareHandler().
|
private |
Remove the given process on the Schedule queue.
Definition at line 414 of file ProcessManager.cpp.
References Scheduler::dequeue(), ERROR, Process::getID(), IOError, m_scheduler, Scheduler::Success, and Success.
Referenced by remove(), setIdle(), sleep(), stop(), and wait().
|
private |
Place the given process on the Schedule queue.
Definition at line 399 of file ProcessManager.cpp.
References assert, Scheduler::enqueue(), ERROR, Process::getID(), IOError, m_scheduler, m_sleepTimerQueue, Queue< T, N >::remove(), Scheduler::Success, and Success.
Referenced by raiseEvent(), remove(), resume(), and wakeup().
Retrieve a Process by it's ID.
id | ProcessID number. |
Definition at line 95 of file ProcessManager.cpp.
References Index< T, N >::get(), and m_procs.
Referenced by ProcessShares::createShare(), ProcessCtlHandler(), ProcessShares::releaseShare(), ARMKernel::trap(), VMCopyHandler(), VMCtlHandler(), VMShareHandler(), and ProcessShares::~ProcessShares().
ProcessManager::Result ProcessManager::interruptNotify | ( | const u32 | vector | ) |
Raise interrupt notifications for a interrupt vector.
vector | Interrupt vector |
Definition at line 376 of file ProcessManager.cpp.
References ERROR, ListIterator< T >::hasCurrent(), InterruptEvent, IOError, m_interruptNotifyList, raiseEvent(), Success, and ProcessEvent::type.
Referenced by Kernel::executeIntVector().
ProcessManager::Result ProcessManager::raiseEvent | ( | Process * | proc, |
const struct ProcessEvent * | event | ||
) |
Raise kernel event for a Process.
proc | Process pointer |
event | Event to raise |
Definition at line 325 of file ProcessManager.cpp.
References enqueueProcess(), ERROR, Process::getID(), IOError, Process::raiseEvent(), Success, Process::Success, and Process::WakeupPending.
Referenced by ProcessShares::createShare(), interruptNotify(), and ProcessShares::~ProcessShares().
ProcessManager::Result ProcessManager::registerInterruptNotify | ( | Process * | proc, |
const u32 | vector | ||
) |
Register an interrupt notification for a Process.
proc | Process pointer |
vector | Interrupt vector number |
Definition at line 344 of file ProcessManager.cpp.
References AlreadyExists, Vector< T >::insert(), m_interruptNotifyList, and Success.
Referenced by ProcessCtlHandler().
Definition at line 100 of file ProcessManager.cpp.
References assert, dequeueProcess(), enqueueProcess(), FATAL, Process::getID(), Process::getState(), m_current, m_idle, m_procs, m_sleepTimerQueue, Process::Ready, Queue< T, N >::remove(), Index< T, N >::remove(), Index< T, N >::size(), Success, Process::Success, unregisterInterruptNotify(), Process::Waiting, and ZERO.
Referenced by IntelKernel::exception(), and ProcessCtlHandler().
ProcessManager::Result ProcessManager::reset | ( | Process * | proc, |
const Address | entry | ||
) |
Restart execution of a Process at the given entry point.
proc | Process pointer |
entry | Address to begin execution. |
Definition at line 262 of file ProcessManager.cpp.
References entry, ERROR, IOError, m_current, Process::reset(), and Success.
Referenced by ProcessCtlHandler().
ProcessManager::Result ProcessManager::resume | ( | Process * | proc | ) |
Resume scheduling of the given Process.
proc | Process pointer |
Definition at line 250 of file ProcessManager.cpp.
References enqueueProcess(), ERROR, Process::getID(), IOError, Process::resume(), and Process::Success.
Referenced by create(), and ProcessCtlHandler().
ProcessManager::Result ProcessManager::schedule | ( | ) |
Schedule next process to run.
Definition at line 155 of file ProcessManager.cpp.
References Queue< T, N >::count(), Process::execute(), FATAL, Process::getID(), Process::getSleepTimer(), Kernel::getTimer(), WeakSingleton< Kernel >::instance(), Timer::isExpired(), m_current, m_idle, m_scheduler, m_sleepTimerQueue, Queue< T, N >::pop(), Queue< T, N >::push(), Scheduler::select(), Success, and wakeup().
Referenced by IntelKernel::clocktick(), IntelKernel::exception(), SunxiKernel::interrupt(), RaspberryKernel::interrupt(), ProcessCtlHandler(), and Kernel::run().
void ProcessManager::setIdle | ( | Process * | proc | ) |
Set the idle process.
Definition at line 208 of file ProcessManager.cpp.
References dequeueProcess(), FATAL, Process::getID(), m_idle, and Success.
Referenced by PrivExecHandler().
ProcessManager::Result ProcessManager::sleep | ( | const Timer::Info * | timer = 0 , |
const bool | ignoreWakeups = false |
||
) |
Let current Process sleep until a timer expires or wakeup occurs.
timer | Timer on which the process must be woken up (if expired), or ZERO for no limit |
ignoreWakeups | True to enter Sleep state regardless of pending wakeups |
Definition at line 274 of file ProcessManager.cpp.
References assert, Queue< T, N >::contains(), dequeueProcess(), ERROR, FATAL, Process::getID(), IOError, m_current, m_sleepTimerQueue, Queue< T, N >::push(), Process::sleep(), Success, Process::Success, WakeupPending, and Process::WakeupPending.
Referenced by ProcessCtlHandler().
ProcessManager::Result ProcessManager::stop | ( | Process * | proc | ) |
Remove given Process from the Scheduler.
proc | Process pointer |
Definition at line 230 of file ProcessManager.cpp.
References dequeueProcess(), ERROR, Process::getID(), Process::getState(), IOError, Process::Ready, Process::stop(), Success, and Process::Success.
Referenced by ProcessCtlHandler().
ProcessManager::Result ProcessManager::unregisterInterruptNotify | ( | Process * | proc | ) |
Remove all interrupt notifications for a Process.
proc | Process pointer |
Definition at line 361 of file ProcessManager.cpp.
References m_interruptNotifyList, List< T >::remove(), Vector< T >::size(), and Success.
Referenced by remove().
ProcessManager::Result ProcessManager::wait | ( | Process * | proc | ) |
Let current Process wait for another Process to terminate.
proc | Process pointer |
Definition at line 219 of file ProcessManager.cpp.
References dequeueProcess(), ERROR, Process::getID(), IOError, m_current, Process::Success, and Process::wait().
Referenced by ProcessCtlHandler().
ProcessManager::Result ProcessManager::wakeup | ( | Process * | proc | ) |
Take Process out of Sleep state and mark ready for execution.
proc | Process pointer |
Definition at line 306 of file ProcessManager.cpp.
References enqueueProcess(), ERROR, Process::getID(), IOError, Success, Process::Success, Process::wakeup(), and Process::WakeupPending.
Referenced by ProcessCtlHandler(), and schedule().
|
private |
Currently executing process.
Definition at line 243 of file ProcessManager.h.
Referenced by create(), current(), ProcessManager(), remove(), reset(), schedule(), sleep(), and wait().
|
private |
Idle process.
Definition at line 246 of file ProcessManager.h.
Referenced by ProcessManager(), remove(), schedule(), and setIdle().
Interrupt notification list.
Definition at line 252 of file ProcessManager.h.
Referenced by interruptNotify(), ProcessManager(), registerInterruptNotify(), and unregisterInterruptNotify().
All known Processes.
Definition at line 237 of file ProcessManager.h.
|
private |
Object which selects processes to run.
Definition at line 240 of file ProcessManager.h.
Referenced by dequeueProcess(), enqueueProcess(), ProcessManager(), schedule(), and ~ProcessManager().
Queue with sleeping processes waiting for a Timer to expire.
Definition at line 249 of file ProcessManager.h.
Referenced by enqueueProcess(), remove(), schedule(), and sleep().