00001 /* header file for src/thread/process.cpp */ 00002 00003 #ifndef _CORE_THREAD_PROCESS_HPP 00004 #define _CORE_THREAD_PROCESS_HPP 00005 00006 //necessary includes 00007 #include "src/common/blist.hpp" 00008 #include "src/memory/pager.hpp" 00009 #include "src/memory/heap.hpp" 00010 #include "src/arch/x86/except_c.hpp" 00011 #include "src/thread/thread.hpp" 00012 00013 struct procenv_t 00014 { 00015 int api; //which api does the process use 00016 }; 00017 00018 struct env_t 00019 { 00020 class Thread::process_t *proc; 00021 class Thread::thread_t *thread; 00022 class Memory::Pager::memtree *mtree; 00023 struct ::Arch::x86::Interr::except2_t *code; 00024 }; 00025 00026 int EnvGet(struct env_t *env); //get current env info 00027 00028 namespace Thread { 00029 00030 00031 const uint32 DEF_THREAD_PRIOR = 0x5; //the priority a thread gets at start 00032 const uint32 PROC_NAME = 0x10; 00033 00034 extern class blist_t Processes; //the list of processes in system 00035 int ProcessRegister(class process_t *proc); 00036 int ProcessKill(int no); //kill a process by killing all it's threads 00037 process_t *ProcessGet(int i); //grab a process' struct knowing it's num 00038 00039 00040 00041 //a process' datatype 00042 class process_t 00043 { 00044 public: 00045 blist_t thread_list; //thread list 00046 class Memory::Pager::memtree *mem; //address space info 00047 class Memory::Heap::heapbox heap; //the process' kernel data*/ 00048 struct procenv_t env; //process environment 00049 00050 int no; //the no. of the process 00051 int max_thread_no; //the last created thread's no 00052 char name[PROC_NAME]; 00053 void init(char *nam, Memory::Pager::memtree *mtree); //init 00054 void InitKeepHeap(const char *c, Memory::Pager::memtree *mtree);//init 00055 00056 thread_t *create_thread(bool supervisor, uint32 proc_addr, 00057 uint32 worst_priority, uint32 best_priority, const char name[]); //create a new thread 00058 00059 uint32 alloc_stack(bool supervisor, size_t size, uint32 threadno); //allocate a stack 00060 }; 00061 00062 extern process_t kernel_process; //the kernel process 00063 00064 }; /*namespace Thread*/ 00065 00066 #define ProcFail(...) do { complain(__VA_ARGS__); ::Thread::ProcessKill(current_thread->proc->no); } while (0) 00067 00068 #endif