summaryrefslogtreecommitdiff
path: root/src/kernel/task/task.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/task/task.cpp')
-rw-r--r--src/kernel/task/task.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/kernel/task/task.cpp b/src/kernel/task/task.cpp
index 5dea33b..3863850 100644
--- a/src/kernel/task/task.cpp
+++ b/src/kernel/task/task.cpp
@@ -204,7 +204,6 @@ void process_exit(size_t retval) {
(its address is the value given for EIP).
It switches to user mode if necessary and calls the entry point. */
static void thread_run(void* u_esp, thread *thread, thread_entry entry_point, void *data) {
- asm volatile("cli");
pagedir_switch(thread->process->pagedir);
if (thread->process->privilege >= PL_USER) { //User mode !
uint32_t *stack = (uint32_t*)u_esp;
@@ -237,7 +236,6 @@ static void thread_run(void* u_esp, thread *thread, thread_entry entry_point, vo
push %%eax; \
pushl $0x1B; \
push %%ecx; \
- sti; \
iret; \
" : : "b"(esp), "c"(eip));
} else {
@@ -269,12 +267,9 @@ thread::thread(class process *proc, thread_entry entry_point, void *data, void *
stack--; *stack = (uint32_t)u_esp;
stack--; *stack = 0;
esp = (uint32_t)stack;
- ebp = esp + 8;
+ ebp = esp + 16;
eip = (uint32_t)thread_run;
- state = TS_RUNNING;
- sched_enqueue(this);
-
if (proc->threads == 0) {
proc->threads = this;
} else {
@@ -282,6 +277,9 @@ thread::thread(class process *proc, thread_entry entry_point, void *data, void *
while (i->next != 0) i = i->next;
i->next = this;
}
+
+ state = TS_RUNNING;
+ sched_enqueue(this);
}
/* Creates a new process. Creates a struct process and fills it up. */
@@ -310,6 +308,7 @@ process::process(process* _parent, uint32_t _uid, uint32_t _privilege) : fd(12,
/* Deletes given thread, freeing the stack(s). */
static void thread_delete(thread *th) {
+ sched_remove(th);
if (th->process->threads == th) {
th->process->threads = th->next;
} else {
@@ -332,7 +331,6 @@ static void thread_delete(thread *th) {
static void process_finish(process *pr, int retval) {
proc_retval->set(pr->pid, (void*)retval);
-
thread *it = pr->threads;
while (it != 0) {
thread_delete(it);