diff --git a/hermit/arch/x86/kernel/tasks.c b/hermit/arch/x86/kernel/tasks.c index 10d746554..b10bbdabe 100644 --- a/hermit/arch/x86/kernel/tasks.c +++ b/hermit/arch/x86/kernel/tasks.c @@ -112,7 +112,12 @@ static int thread_entry(void* arg, size_t ep) size_t* get_current_stack(void) { task_t* curr_task = per_core(current_task); - size_t stptr = (size_t) curr_task->stack + KERNEL_STACK_SIZE - 0x10; + size_t stptr = (size_t) curr_task->stack; + + if (curr_task->status == TASK_IDLE) + stptr += KERNEL_STACK_SIZE - 0x10; + else + stptr += DEFAULT_STACK_SIZE - 0x10; set_per_core(kernel_stack, stptr); tss_set_rsp0(stptr); @@ -138,15 +143,15 @@ int create_default_frame(task_t* task, entry_point_t ep, void* arg, uint32_t cor if (BUILTIN_EXPECT(!task->stack, 0)) return -EINVAL; - kprintf("Task %d use use the memory region [%p - %p] as kernel stack\n", task->id, task->stack, (char*) task->stack + KERNEL_STACK_SIZE - 1); + kprintf("Task %d use use the memory region [%p - %p] as kernel stack\n", task->id, task->stack, (char*) task->stack + DEFAULT_STACK_SIZE - 1); - memset(task->stack, 0xCD, KERNEL_STACK_SIZE); + memset(task->stack, 0xCD, DEFAULT_STACK_SIZE); /* The difference between setting up a task for SW-task-switching * and not for HW-task-switching is setting up a stack and not a TSS. * This is the stack which will be activated and popped off for iret later. */ - stack = (size_t*) (((size_t) task->stack + KERNEL_STACK_SIZE - 0x10) & ~0xF); // => stack is 16byte aligned + stack = (size_t*) (((size_t) task->stack + DEFAULT_STACK_SIZE - 0x10) & ~0xF); // => stack is 16byte aligned /* Only marker for debugging purposes, ... */ *stack-- = 0xDEADBEEF; diff --git a/hermit/include/hermit/config.h b/hermit/include/hermit/config.h index e4b625cc0..e2bd8cb0f 100644 --- a/hermit/include/hermit/config.h +++ b/hermit/include/hermit/config.h @@ -40,8 +40,8 @@ extern "C" { #define CLOCK_TICK_RATE 1193182 /* 8254 chip's internal oscillator frequency */ #define VIDEO_MEM_ADDR 0xB8000 /* the video memory address */ #define CACHE_LINE 64 -#define KERNEL_STACK_SIZE (8<<10) /* 8 KiB */ -#define DEFAULT_STACK_SIZE (64*1024) /* 16 KiB */ +#define KERNEL_STACK_SIZE (8*1024) +#define DEFAULT_STACK_SIZE (128*1024) #define KMSG_SIZE (4*1024) #define INT_SYSCALL 0x80 #define MAILBOX_SIZE 32 diff --git a/hermit/kernel/tasks.c b/hermit/kernel/tasks.c index f0c1c99b4..f0200f89a 100644 --- a/hermit/kernel/tasks.c +++ b/hermit/kernel/tasks.c @@ -342,7 +342,7 @@ int clone_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio) curr_task = per_core(current_task); - stack = kmalloc(KERNEL_STACK_SIZE); + stack = kmalloc(DEFAULT_STACK_SIZE); if (BUILTIN_EXPECT(!stack, 0)) return -ENOMEM; @@ -432,7 +432,7 @@ int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t c curr_task = per_core(current_task); - stack = kmalloc(KERNEL_STACK_SIZE); + stack = kmalloc(DEFAULT_STACK_SIZE); if (BUILTIN_EXPECT(!stack, 0)) return -ENOMEM;