summaryrefslogtreecommitdiff
path: root/src/kernel/task/task.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/task/task.c')
-rw-r--r--src/kernel/task/task.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/kernel/task/task.c b/src/kernel/task/task.c
index 9d98165..4c99bf7 100644
--- a/src/kernel/task/task.c
+++ b/src/kernel/task/task.c
@@ -7,6 +7,8 @@
#include <mem/gdt.h>
#include "timer.h"
+#include <Object/Object.h>
+
#define KSTACKSIZE 0x8000
//Static routines for handling threads exiting and all cleanup
@@ -286,6 +288,13 @@ struct process *process_new(struct process* parent, uint32_t uid, uint32_t privi
p->data = 0;
p->dataseg = 0;
+ p->handles.ref_vect_init_len = 32;
+ p->handles.vect_len = 128;
+ p->handles.data = 0;
+ earray_init(&p->handles);
+ ASSERT(earray_add(&p->handles, 0xFFFFFFF0) == 0);
+ ASSERT(earray_add(&p->handles, 0xFFFFFFF0) == 1);
+
p->stack = 0;
if (p->privilege >= PL_USER) { //We are running in user mode
size_t stacksBottom = K_HIGHHALF_ADDR - 0x01000000;
@@ -319,6 +328,8 @@ static void thread_delete(struct thread *th) {
/* Deletes a process. First, deletes all its threads. Also deletes the corresponding page directory. */
static void process_delete(struct process *pr) {
+ int i;
+
struct thread *it = pr->threads;
while (it != 0) {
thread_delete(it);
@@ -336,31 +347,19 @@ static void process_delete(struct process *pr) {
it = it->next;
}
}
+ for (i = 1; i < pr->handles.elements; i++) {
+ Object* obj = earray_at(&pr->handles, i);
+ if (obj != 0) {
+ obj->handles--;
+ if (obj->_class->closed != 0) obj->_class->closed(obj);
+ }
+ }
+ earray_free(&pr->handles);
+
pagedir_delete(pr->pagedir);
kfree(pr);
}
-/* System call. Called by the app to define the place for the heap. */
-/*int process_setheapseg(size_t start, size_t end) { //syscall
- struct process *p = current_thread->process;
- if (start >= K_HIGHHALF_ADDR || end >= K_HIGHHALF_ADDR) return -1;
- if (p->heapseg == 0) {
- struct segment *s = simpleseg_make(start, end - start, 1);
- if (s == 0) return -5;
- p->heapseg = seg_map(s, p->pagedir, 0);
- if (p->heapseg == 0) return -1;
- return 0;
- } else if (p->heapseg->start != start) {
- seg_unmap(p->heapseg);
- struct segment *s = simpleseg_make(start, end - start, 1);
- if (s == 0) return -5;
- p->heapseg = seg_map(s, p->pagedir, 0);
- if (p->heapseg == 0) return -1;
- return 0;
- } else {
- return simpleseg_resize(p->heapseg, end - start);
- }
-}*/
size_t process_sbrk(size_t size) {
struct process *p = current_thread->process;