Go to the documentation of this file.
18 #include <FreeNOS/System.h>
27 , m_interruptNotifyList(256)
47 const bool readyToRun,
48 const bool privileged)
62 ERROR(
"failed to allocate Process");
71 ERROR(
"failed to initialize Process: result = " << (
int) result);
110 for (
Size i = 0; i < size; i++)
120 ": result = " << (
int) result);
126 FATAL(
"failed to enqueue() PID " <<
m_procs[i]->getID() <<
127 ": result = " << (
int) r);
143 FATAL(
"failed to dequeue PID " << proc->
getID());
148 assert(countRemoved <= 1U);
169 FATAL(
"no process found to run!");
173 for (
Size i = 0; i < sleepTimerCount; i++)
213 FATAL(
"failed to dequeue PID " << proc->
getID());
236 ERROR(
"failed to stop PID " << proc->
getID() <<
": result = " << (
int) result);
255 ERROR(
"failed to resume PID " << proc->
getID() <<
": result = " << (
int) result);
266 ERROR(
"cannot reset current Process");
299 ": result: " << (
uint) result);
319 ERROR(
"failed to wakeup process ID " << proc->
getID() <<
320 ": result: " << (
uint) result);
338 ERROR(
"failed to raise event in process ID " << proc->
getID() <<
339 ": result: " << (
uint) result);
383 event.number = vector;
389 ERROR(
"failed to raise InterruptEvent for IRQ #" << vector <<
390 " on Process ID " << i.current()->getID());
403 ERROR(
"process ID " << proc->
getID() <<
" not added to Scheduler");
408 assert(countRemoved <= 1U);
418 ERROR(
"process ID " << proc->
getID() <<
" not removed from Scheduler");
Responsible for deciding which Process may execute on the local Core.
Result resume(Process *proc)
Resume scheduling of the given Process.
Process * m_idle
Idle process.
Size remove(T value)
Remove all items with the given value.
Result raiseEvent(Process *proc, const struct ProcessEvent *event)
Raise kernel event for a Process.
virtual ~ProcessManager()
Destructor function.
virtual void reset(const Address entry)=0
Restart execution at the given entry point.
virtual bool insertAt(const Size position, T *item)
Inserts the given item at the given position.
bool contains(const T &item) const
Look if an item exists on the Queue.
State getState() const
Retrieves the current state.
Represents a process which may run on the host.
Result reset(Process *proc, const Address entry)
Restart execution of a Process at the given entry point.
Result raiseEvent(const struct ProcessEvent *event)
Raise kernel event.
Process * m_current
Currently executing process.
Process * create(const Address entry, const MemoryMap &map, const bool readyToRun=false, const bool privileged=false)
Create a new Process.
Result unregisterInterruptNotify(Process *proc)
Remove all interrupt notifications for a Process.
ProcessID getID() const
Retrieve our ID number.
Result dequeueProcess(Process *proc, const bool ignoreState=false) const
Remove the given process on the Schedule queue.
Result sleep(const Timer::Info *timer=0, const bool ignoreWakeups=false)
Let current Process sleep until a timer expires or wakeup occurs.
u32 ProcessID
Process Identification Number.
unsigned long Address
A memory address.
Result wakeup(Process *proc)
Take Process out of Sleep state and mark ready for execution.
Result wait(Process *proc)
Let current Process wait for another Process to terminate.
Timer information structure.
Represents a configurable timer device.
Result wakeup()
Prevent process from sleeping.
virtual void fill(T value)
Fill the Sequence with the given value.
unsigned int uint
Unsigned integer number.
virtual int remove(T t)
Remove all items which are equal to the given item.
Result stop()
Stop execution of this process.
#define FATAL(msg)
Output a critical message and terminate program immediatly.
#define DEBUG(msg)
Output a debug message to standard output.
Result resume()
Resume execution when this process is stopped.
Result stop(Process *proc)
Remove given Process from the Scheduler.
Represents a process which may run on the host.
virtual bool hasCurrent() const
Check if there is a current item on the List.
virtual void execute(Process *previous)=0
Allow the Process to run on the CPU.
#define MAX_PROCS
Maximum number of processes.
virtual Size size() const
Size of the Index.
#define NULL
NULL means zero.
Process * select()
Select the next process to run.
unsigned int u32
Unsigned 32-bit number.
ProcessManager()
Constructor function.
Describes virtual memory map layout.
unsigned int Size
Any sane size indicator cannot go negative.
static Kernel * instance()
Retrieve the instance.
Result schedule()
Schedule next process to run.
virtual int insert(const T &item)
Adds the given item to the Vector, if possible.
bool isExpired(const Info &info) const
Check if a timer value is expired.
virtual Size size() const
Returns the maximum size of this Vector.
virtual T * get(const Size position) const
Returns the item at the given position.
Process * get(const ProcessID id)
Retrieve a Process by it's ID.
void setParent(ProcessID id)
Set parent process ID.
Result enqueue(Process *proc, bool ignoreState)
Add a Process to the run schedule.
Index< Process, MAX_PROCS > m_procs
All known Processes.
virtual Size count() const
Returns the number of items in the Queue.
Result interruptNotify(const u32 vector)
Raise interrupt notifications for a interrupt vector.
virtual Result initialize()
Initialize the Process.
#define assert(exp)
Insert program diagnostics.
State
Represents the execution state of the Process.
#define ERROR(msg)
Output an error message.
void remove(Process *proc, const uint exitStatus=0)
Remove a Process.
Result sleep(const Timer::Info *timer, bool ignoreWakeups)
Stops the process for executing until woken up.
T & pop()
Remove item from the tail of the Queue.
virtual bool remove(const Size position)
Removes the item at the given position.
bool push(const T &item)
Add item to the head of the Queue.
Queue< Process *, MAX_PROCS > m_sleepTimerQueue
Queue with sleeping processes waiting for a Timer to expire.
Scheduler * m_scheduler
Object which selects processes to run.
Process * current()
Current process running.
Result dequeue(Process *proc, bool ignoreState)
Remove a Process from the run schedule.
virtual bool insert(Size &position, T *item)
Adds the given item, if possible.
const Timer::Info & getSleepTimer() const
Get sleep timer.
Timer * getTimer()
Get Timer.
void setIdle(Process *proc)
Set the idle process.
Result wait(ProcessID id)
Let Process wait for other Process to terminate.
Vector< List< Process * > * > m_interruptNotifyList
Interrupt notification list.
Result registerInterruptNotify(Process *proc, const u32 vector)
Register an interrupt notification for a Process.
Result enqueueProcess(Process *proc, const bool ignoreState=false)
Place the given process on the Schedule queue.