summaryrefslogtreecommitdiff
path: root/Source/Kernel/TaskManager
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-09-13 19:41:13 +0200
committerAlexis211 <alexis211@gmail.com>2009-09-13 19:41:13 +0200
commite0d27cc75009e27502d57258cb64c71221b4b7d1 (patch)
tree0898ab1a033d27fbd527b636b70a3805ea97ea13 /Source/Kernel/TaskManager
parentd25429b738cb9c1b34d234ae23b3af27fdff72ea (diff)
downloadMelon-e0d27cc75009e27502d57258cb64c71221b4b7d1.tar.gz
Melon-e0d27cc75009e27502d57258cb64c71221b4b7d1.zip
Class for file descriptors introduced : File. Not used yet.
Diffstat (limited to 'Source/Kernel/TaskManager')
-rw-r--r--Source/Kernel/TaskManager/Process.class.cpp22
-rw-r--r--Source/Kernel/TaskManager/Process.class.h5
2 files changed, 26 insertions, 1 deletions
diff --git a/Source/Kernel/TaskManager/Process.class.cpp b/Source/Kernel/TaskManager/Process.class.cpp
index f94e652..ec1fcc9 100644
--- a/Source/Kernel/TaskManager/Process.class.cpp
+++ b/Source/Kernel/TaskManager/Process.class.cpp
@@ -1,6 +1,7 @@
#include "Process.class.h"
#include <TaskManager/Task.ns.h>
#include <MemoryManager/PhysMem.ns.h>
+#include <VFS/File.class.h>
Process::Process() { //Private constructor, does nothing
}
@@ -40,7 +41,7 @@ Process::Process(String cmdline, u32int uid) {
m_stacksstart = 0xC0000000;
}
-Process::~Process() { //TODO : clean up process
+Process::~Process() {
exit(); //Kill all threads
delete m_pagedir;
}
@@ -59,6 +60,11 @@ void Process::exit() {
delete m_threads.back();
m_threads.pop();
}
+ for (u32int i = 0; i < m_fileDescriptors.size(); i++) {
+ m_fileDescriptors[i]->close(false);
+ delete m_fileDescriptors[i];
+ }
+ m_fileDescriptors.clear();
m_state = P_FINISHED;
}
@@ -82,6 +88,20 @@ void Process::threadFinishes(Thread* thread, u32int retval) {
}
}
+void Process::registerFileDescriptor(File* fd) {
+ m_fileDescriptors.push(fd);
+}
+
+void Process::unregisterFileDescriptor(File* fd) {
+ for (u32int i = 0; i < m_fileDescriptors.size(); i++) {
+ if (m_fileDescriptors[i] == fd) {
+ m_fileDescriptors[i] = m_fileDescriptors.back();
+ m_fileDescriptors.pop();
+ break;
+ }
+ }
+}
+
PageDirectory* Process::getPagedir() {
return m_pagedir;
}
diff --git a/Source/Kernel/TaskManager/Process.class.h b/Source/Kernel/TaskManager/Process.class.h
index 581d6b1..8b0a030 100644
--- a/Source/Kernel/TaskManager/Process.class.h
+++ b/Source/Kernel/TaskManager/Process.class.h
@@ -17,6 +17,7 @@
#define STACKSIZE 4096 //Can change
class Thread;
+class File;
class Process {
friend class Thread;
@@ -34,6 +35,7 @@ class Process {
VirtualTerminal *m_vt;
Vector<Thread*> m_threads;
+ Vector<File*> m_fileDescriptors;
public:
static Process* createKernel(String cmdline, VirtualTerminal *vt); //Also creates a Thread for what's curently happening
@@ -45,6 +47,9 @@ class Process {
void registerThread(Thread* t); //Called when a thread starts
void threadFinishes(Thread* thread, u32int retval); //Called when a thread finishes
+ void registerFileDescriptor(File* fd);
+ void unregisterFileDescriptor(File* fd);
+
PageDirectory* getPagedir();
VirtualTerminal* getVirtualTerminal();