diff options
author | Alexis211 <alexis211@gmail.com> | 2009-08-29 13:39:06 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-08-29 13:39:06 +0200 |
commit | c92beeedda51487696ce476ee30604f22e7b2270 (patch) | |
tree | 29b89d31b0b35792e1ed2bc5861be0439e7e40d9 /Source/Kernel/TaskManager/Process.class.h | |
parent | 5deab22107fc38bd2bea19f07889b14c376754e0 (diff) | |
download | Melon-c92beeedda51487696ce476ee30604f22e7b2270.tar.gz Melon-c92beeedda51487696ce476ee30604f22e7b2270.zip |
The Melon kernel now has support for simple multitasking
Diffstat (limited to 'Source/Kernel/TaskManager/Process.class.h')
-rw-r--r-- | Source/Kernel/TaskManager/Process.class.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Source/Kernel/TaskManager/Process.class.h b/Source/Kernel/TaskManager/Process.class.h new file mode 100644 index 0000000..4ee7fcf --- /dev/null +++ b/Source/Kernel/TaskManager/Process.class.h @@ -0,0 +1,50 @@ +#ifndef DEF_PROCESS_CLASS_H +#define DEF_PROCESS_CLASS_H + +#include <Library/String.class.h> +#include <Library/Vector.class.h> +#include <MemoryManager/PageDirectory.class.h> + +#define P_ZOMBIE 0 +#define P_RUNNING 1 +#define P_FINISHED 2 + +#define E_PAGEFAULT 0x0FFFFF00 +#define E_ABORTED 0x0FFFFF01 +#define E_EXCEPTION 0x0FFFFF02 + +#define STACKSIZE 4096 //Can change + +class Thread; + +class Process { + friend class Thread; + + private: + Process(); //Creates an empty process, used by creatKernel() + + u32int m_pid; + String m_cmdline; + s32int m_retval; //Can be either a standard return value or an E_* (see #defines above) + u8int m_state; //Is one of P_* defined above + PageDirectory* m_pagedir; + u32int m_uid; //User ID + u32int m_stacksstart; + + Vector<Thread*> m_threads; + + public: + static Process* createKernel(String cmdline); //Also creates a Thread for what's curently happening + Process(String cmdline, u32int uid); + ~Process(); + + u32int stackAlloc(); //Allocates pages for STACKSIZE bytes at end of app memory (just before 0xC0000000) + void exit(); //Exits properly process by killing all threads + void registerThread(Thread* t); //Called when a thread starts + void threadFinishes(Thread* thread, u32int retval); //Called when a thread finishes + + PageDirectory* getPagedir(); + +}; + +#endif |