FreeNOS
ProcessManager.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __KERNEL_PROCESS_MANAGER_H
19#define __KERNEL_PROCESS_MANAGER_H
20
21#include <Types.h>
22#include <MemoryMap.h>
23#include <Vector.h>
24#include <List.h>
25#include <Queue.h>
26#include "Process.h"
27
28/* Forward declarations */
29class Scheduler;
30
39#define MAX_PROCS 1024
40
45{
46 public:
47
59
60 public:
61
66
70 virtual ~ProcessManager();
71
83 const MemoryMap &map,
84 const bool readyToRun = false,
85 const bool privileged = false);
86
94 Process * get(const ProcessID id);
95
99 void remove(Process *proc, const uint exitStatus = 0);
100
107
115 Result wait(Process *proc);
116
124 Result stop(Process *proc);
125
133 Result resume(Process *proc);
134
141 Result reset(Process *proc, const Address entry);
142
151 Result sleep(const Timer::Info *timer = 0, const bool ignoreWakeups = false);
152
160 Result wakeup(Process *proc);
161
170 Result raiseEvent(Process *proc, const struct ProcessEvent *event);
171
180 Result registerInterruptNotify(Process *proc, const u32 vector);
181
190
198 Result interruptNotify(const u32 vector);
199
203 void setIdle(Process *proc);
204
210 Process * current();
211
212 private:
213
222 Result enqueueProcess(Process *proc, const bool ignoreState = false);
223
232 Result dequeueProcess(Process *proc, const bool ignoreState = false) const;
233
234 private:
235
238
241
244
247
250
253};
254
259#endif /* __KERNEL_PROCESS_MANAGER_H */
u32 entry[]
Definition IntelACPI.h:1
Index is a N-sized array of pointers to items of type T.
Definition Index.h:37
Describes virtual memory map layout.
Definition MemoryMap.h:39
Represents a process which may run on the host.
Result unregisterInterruptNotify(Process *proc)
Remove all interrupt notifications for a Process.
Result reset(Process *proc, const Address entry)
Restart execution of a Process at the given entry point.
Result registerInterruptNotify(Process *proc, const u32 vector)
Register an interrupt notification for a Process.
ProcessManager()
Constructor function.
void setIdle(Process *proc)
Set the idle process.
Result resume(Process *proc)
Resume scheduling of the given Process.
Result sleep(const Timer::Info *timer=0, const bool ignoreWakeups=false)
Let current Process sleep until a timer expires or wakeup occurs.
Result dequeueProcess(Process *proc, const bool ignoreState=false) const
Remove the given process on the Schedule queue.
Scheduler * m_scheduler
Object which selects processes to run.
Result wait(Process *proc)
Let current Process wait for another Process to terminate.
Result
Result code.
Process * create(const Address entry, const MemoryMap &map, const bool readyToRun=false, const bool privileged=false)
Create a new Process.
Process * m_idle
Idle process.
Result wakeup(Process *proc)
Take Process out of Sleep state and mark ready for execution.
void remove(Process *proc, const uint exitStatus=0)
Remove a Process.
Vector< List< Process * > * > m_interruptNotifyList
Interrupt notification list.
Result raiseEvent(Process *proc, const struct ProcessEvent *event)
Raise kernel event for a Process.
Queue< Process *, MAX_PROCS > m_sleepTimerQueue
Queue with sleeping processes waiting for a Timer to expire.
Result stop(Process *proc)
Remove given Process from the Scheduler.
Result schedule()
Schedule next process to run.
Process * m_current
Currently executing process.
Result enqueueProcess(Process *proc, const bool ignoreState=false)
Place the given process on the Schedule queue.
Result interruptNotify(const u32 vector)
Raise interrupt notifications for a interrupt vector.
virtual ~ProcessManager()
Destructor function.
Process * get(const ProcessID id)
Retrieve a Process by it's ID.
Process * current()
Current process running.
Index< Process, MAX_PROCS > m_procs
All known Processes.
Represents a process which may run on the host.
Definition Process.h:45
Array of items as a First-In-First-Out (FIFO) datastructure.
Definition Queue.h:37
Responsible for deciding which Process may execute on the local Core.
Definition Scheduler.h:37
Vectors are dynamically resizeable Arrays.
Definition Vector.h:42
u32 ProcessID
Process Identification Number.
Definition Types.h:140
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned long Address
A memory address.
Definition Types.h:131
unsigned int uint
Unsigned integer number.
Definition Types.h:44
Represents a process which may run on the host.
Timer information structure.
Definition Timer.h:43