From 866580161b826443bed3862b8315cefd505de37c Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Tue, 20 Oct 2009 18:10:29 +0200 Subject: We now have call tables for ressources. instead of adding calls to ressource in the constructor. --- Source/Kernel/TaskManager/Process.class.cpp | 14 +++++++++----- Source/Kernel/TaskManager/Process.class.h | 9 +++++---- Source/Kernel/TaskManager/Thread.class.cpp | 15 +++++++++------ Source/Kernel/TaskManager/Thread.class.h | 9 +++++---- 4 files changed, 28 insertions(+), 19 deletions(-) (limited to 'Source/Kernel/TaskManager') diff --git a/Source/Kernel/TaskManager/Process.class.cpp b/Source/Kernel/TaskManager/Process.class.cpp index aae8fce..7ebac72 100644 --- a/Source/Kernel/TaskManager/Process.class.cpp +++ b/Source/Kernel/TaskManager/Process.class.cpp @@ -9,7 +9,14 @@ namespace Mem { extern Heap kheap; } -Process::Process() : Ressource(PR_IFACE_OBJTYPE) { //Private constructor, does nothing +call_t Process::m_callTable[] = { + CALL0(PRIF_EXIT, &Process::exitSC), + CALL1(PRIF_ALLOCPAGE, &Process::allocPageSC), + CALL1(PRIF_FREEPAGE, &Process::freePageSC), + CALL0(0, 0) +}; + +Process::Process() : Ressource(PRIF_OBJTYPE, m_callTable) { //Private constructor, does nothing } Process* Process::createKernel(String cmdline, VirtualTerminal *vt) { @@ -54,10 +61,7 @@ Process* Process::run(String filename, FSNode* cwd, u32int uid) { } } -Process::Process(String cmdline, u32int uid) : Ressource(PR_IFACE_OBJTYPE) { - addCall0(PR_IFACE_EXIT, (call0)&Process::exitSC); - addCall1(PR_IFACE_ALLOCPAGE, (call1)&Process::allocPageSC); - addCall1(PR_IFACE_FREEPAGE, (call1)&Process::freePageSC); +Process::Process(String cmdline, u32int uid) : Ressource(PRIF_OBJTYPE, m_callTable) { m_pid = Task::nextPid(); m_cmdline = cmdline; m_retval = 0; diff --git a/Source/Kernel/TaskManager/Process.class.h b/Source/Kernel/TaskManager/Process.class.h index afdfe20..0013dfb 100644 --- a/Source/Kernel/TaskManager/Process.class.h +++ b/Source/Kernel/TaskManager/Process.class.h @@ -46,6 +46,11 @@ class Process : public Ressource { Vector m_threads; SimpleList *m_fileDescriptors; + + //System calls + static call_t m_callTable[]; + u32int exitSC(); + u32int allocPageSC(u32int); public: static Process* createKernel(String cmdline, VirtualTerminal *vt); //Also creates a Thread for what's curently happening @@ -68,10 +73,6 @@ class Process : public Ressource { VirtualTerminal* getVirtualTerminal(); void setVirtualTerminal(VirtualTerminal* vt); u32int getState() { return m_state; } - - //System calls - u32int exitSC(); - u32int allocPageSC(u32int); u32int freePageSC(u32int); }; diff --git a/Source/Kernel/TaskManager/Thread.class.cpp b/Source/Kernel/TaskManager/Thread.class.cpp index 98fa32d..d846630 100644 --- a/Source/Kernel/TaskManager/Thread.class.cpp +++ b/Source/Kernel/TaskManager/Thread.class.cpp @@ -6,6 +6,12 @@ #include +call_t Thread::m_callTable[] = { + CALL1(THIF_SLEEP, &Thread::sleepSC), + CALL1(THIF_FINISH, &Thread::finishSC), + CALL0(0, 0) +}; + void runThread(Thread* thread, void* data, thread_entry_t entry_point) { if (thread->m_isKernel) { asm volatile("sti"); @@ -51,11 +57,11 @@ void runThread(Thread* thread, void* data, thread_entry_t entry_point) { } } -Thread::Thread() : Ressource(TH_IFACE_OBJTYPE) { //Private constructor, does nothing +Thread::Thread() : Ressource(THIF_OBJTYPE, m_callTable) { //Private constructor, does nothing m_xchgspace = 0; } -Thread::Thread(thread_entry_t entry_point, void* data, bool iskernel) : Ressource(TH_IFACE_OBJTYPE) { +Thread::Thread(thread_entry_t entry_point, void* data, bool iskernel) : Ressource(THIF_OBJTYPE, m_callTable) { if (iskernel) { setup(Task::getKernelProcess(), entry_point, data, true); } else { @@ -63,7 +69,7 @@ Thread::Thread(thread_entry_t entry_point, void* data, bool iskernel) : Ressourc } } -Thread::Thread(Process* process, thread_entry_t entry_point, void* data) : Ressource(TH_IFACE_OBJTYPE) { +Thread::Thread(Process* process, thread_entry_t entry_point, void* data) : Ressource(THIF_OBJTYPE, m_callTable) { setup(process, entry_point, data, false); } @@ -81,9 +87,6 @@ Thread::~Thread() { } void Thread::setup(Process* process, thread_entry_t entry_point, void* data, bool isKernel) { - addCall1(TH_IFACE_SLEEP, (call1)&Thread::sleepSC); - addCall1(TH_IFACE_FINISH, (call1)&Thread::finishSC); - m_xchgspace = 0; m_isKernel = isKernel; m_process = process; diff --git a/Source/Kernel/TaskManager/Thread.class.h b/Source/Kernel/TaskManager/Thread.class.h index 42baa86..5938e2e 100644 --- a/Source/Kernel/TaskManager/Thread.class.h +++ b/Source/Kernel/TaskManager/Thread.class.h @@ -37,6 +37,11 @@ class Thread : public Ressource { void setup(Process* process, thread_entry_t entry_point, void* data, bool isKernel); + //Syscalls + static call_t m_callTable[]; + u32int sleepSC(u32int msecs); + u32int finishSC(u32int errcode); + public: Thread(thread_entry_t entry_point, void* data, bool iskernel = false); //Assumes process is current process, or is kprocess if isk Thread(Process* process, thread_entry_t entry_point, void* data); @@ -63,10 +68,6 @@ class Thread : public Ressource { } return false; } - - //Syscalls - u32int sleepSC(u32int msecs); - u32int finishSC(u32int errcode); }; #endif -- cgit v1.2.3