From f67c0b7e20ef0816a2d9047fd20346e3ede98b75 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 13 Feb 2015 17:23:29 +0100 Subject: Prepare for user memory management and usermode code --- src/kernel/core/thread.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/kernel/core/thread.c') diff --git a/src/kernel/core/thread.c b/src/kernel/core/thread.c index 3f25add..9d11da2 100644 --- a/src/kernel/core/thread.c +++ b/src/kernel/core/thread.c @@ -107,10 +107,7 @@ static void run_thread(void (*entry)(void*), void* data) { asm volatile("sti"); entry(data); - current_thread->state = T_STATE_FINISHED; - // TODO : add job for deleting the thread, or whatever - yield(); // expected never to return! - ASSERT(false); + exit(); } thread_t *new_thread(entry_t entry, void* data) { thread_t *t = (thread_t*)malloc(sizeof(thread_t)); @@ -147,7 +144,10 @@ thread_t *new_thread(entry_t entry, void* data) { t->current_pd_d = get_kernel_pagedir(); - t->proc = 0; // used by L1 functions + // used by user processes + t->proc = 0; + t->usermem_pf_handler = 0; + t->kmem_violation_handler = 0; return t; } @@ -196,6 +196,13 @@ void pause() { resume_interrupts(st); } +void exit() { + current_thread->state = T_STATE_FINISHED; + // TODO : add job for deleting the thread, or whatever + yield(); // expected never to return! + ASSERT(false); +} + void resume_thread(thread_t *thread, bool run_at_once) { bool st = disable_interrupts(); -- cgit v1.2.3