summaryrefslogtreecommitdiff
path: root/Source/Kernel/TaskManager
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-10-13 19:05:35 +0200
committerAlexis211 <alexis211@gmail.com>2009-10-13 19:05:35 +0200
commit6e87493b8cd156388b075ecace376126a8875283 (patch)
tree5ebaa00318db1a13dce9f2467384540c514bc1bb /Source/Kernel/TaskManager
parent1a163292375eb78735a7b4bf7ca508f9dfda9a20 (diff)
downloadMelon-6e87493b8cd156388b075ecace376126a8875283.tar.gz
Melon-6e87493b8cd156388b075ecace376126a8875283.zip
Process now uses a linked list for associated file descriptors.
Diffstat (limited to 'Source/Kernel/TaskManager')
-rw-r--r--Source/Kernel/TaskManager/Process.class.cpp18
-rw-r--r--Source/Kernel/TaskManager/Process.class.h3
2 files changed, 8 insertions, 13 deletions
diff --git a/Source/Kernel/TaskManager/Process.class.cpp b/Source/Kernel/TaskManager/Process.class.cpp
index 2653269..6b07e7a 100644
--- a/Source/Kernel/TaskManager/Process.class.cpp
+++ b/Source/Kernel/TaskManager/Process.class.cpp
@@ -60,11 +60,11 @@ void Process::exit() {
delete m_threads[i];
}
m_threads.clear();
- for (u32int i = 0; i < m_fileDescriptors.size(); i++) {
- m_fileDescriptors[i]->close(false);
- delete m_fileDescriptors[i];
+ for (SimpleList<File*> *iter = m_fileDescriptors; iter != 0; iter = iter->next()) {
+ iter->v()->close(false);
+ delete iter->v();
}
- m_fileDescriptors.clear();
+ delete m_fileDescriptors;
m_state = P_FINISHED;
}
@@ -91,17 +91,11 @@ void Process::threadFinishes(Thread* thread, u32int retval) {
}
void Process::registerFileDescriptor(File* fd) {
- m_fileDescriptors.push(fd);
+ m_fileDescriptors = m_fileDescriptors->cons(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;
- }
- }
+ m_fileDescriptors = m_fileDescriptors->removeOnce(fd);
}
PageDirectory* Process::getPagedir() {
diff --git a/Source/Kernel/TaskManager/Process.class.h b/Source/Kernel/TaskManager/Process.class.h
index 65a5d8b..b975db1 100644
--- a/Source/Kernel/TaskManager/Process.class.h
+++ b/Source/Kernel/TaskManager/Process.class.h
@@ -3,6 +3,7 @@
#include <Library/String.class.h>
#include <Library/Vector.class.h>
+#include <Library/SimpleList.class.h>
#include <MemoryManager/PageDirectory.class.h>
#include <VTManager/VirtualTerminal.proto.h>
@@ -35,7 +36,7 @@ class Process {
VirtualTerminal *m_vt;
Vector<Thread*> m_threads;
- Vector<File*> m_fileDescriptors;
+ SimpleList<File*> *m_fileDescriptors;
public:
static Process* createKernel(String cmdline, VirtualTerminal *vt); //Also creates a Thread for what's curently happening