diff --git a/hermit/kernel/tasks.c b/hermit/kernel/tasks.c index a23329898..0d69123aa 100644 --- a/hermit/kernel/tasks.c +++ b/hermit/kernel/tasks.c @@ -236,10 +236,6 @@ void NORETURN do_exit(int arg) uint8_t flags = irq_nested_disable(); - // Threads should delete the page table and the heap */ - if (!curr_task->parent) - page_map_drop(); - // decrease the number of active tasks spinlock_irqsave_lock(&readyqueues[core_id].lock); readyqueues[core_id].nr_tasks--; @@ -387,6 +383,7 @@ int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t c uint32_t i; void* stack = NULL; void* counter = NULL; + task_t* curr_task; if (BUILTIN_EXPECT(!ep, 0)) return -EINVAL; @@ -399,6 +396,8 @@ int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t c if (BUILTIN_EXPECT(!readyqueues[core_id].idle, 0)) return -EINVAL; + curr_task = per_core(current_task); + stack = kmalloc(KERNEL_STACK_SIZE); if (BUILTIN_EXPECT(!stack, 0)) return -ENOMEM; @@ -410,8 +409,6 @@ int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t c } atomic_int64_set((atomic_int64_t*) counter, 0); - kprintf("start new thread on core %d with stack address %p\n", core_id, stack); - spinlock_irqsave_lock(&table_lock); for(i=0; ipage_map; task_table[i].user_usage = (atomic_int64_t*) counter; - /* Allocated new PGD or PML4 and copy page table */ - task_table[i].page_map = get_pages(1); - if (BUILTIN_EXPECT(!task_table[i].page_map, 0)) - goto out; - - /* Copy page tables & user frames of current task to new one */ - page_map_copy(&task_table[i]); - if (id) *id = i; //kprintf("Create task %d with pml4 at 0x%llx\n", i, task_table[i].page_map); @@ -469,6 +459,9 @@ int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t c } } + if (!ret) + kprintf("start new thread %d on core %d with stack address %p\n", i, core_id, stack); + out: spinlock_irqsave_unlock(&table_lock);