aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/core/thread.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-13 17:23:29 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-13 17:23:29 +0100
commitf67c0b7e20ef0816a2d9047fd20346e3ede98b75 (patch)
tree7e547ff85cf10777b882fe925800dad4e65e6414 /src/kernel/core/thread.c
parent1ca5c37cee8a9d9c3058746da78240d8dc289a02 (diff)
downloadkogata-f67c0b7e20ef0816a2d9047fd20346e3ede98b75.tar.gz
kogata-f67c0b7e20ef0816a2d9047fd20346e3ede98b75.zip
Prepare for user memory management and usermode code
Diffstat (limited to 'src/kernel/core/thread.c')
-rw-r--r--src/kernel/core/thread.c17
1 files changed, 12 insertions, 5 deletions
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();