From 59038fc67c20a1f04e5d2fd5f9a444e707d1d3ea Mon Sep 17 00:00:00 2001 From: Miguel Date: Wed, 22 Aug 2018 00:52:30 +0200 Subject: userspace and kernelspace taskswitching --- kernel/usermode.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'kernel/usermode.c') diff --git a/kernel/usermode.c b/kernel/usermode.c index 81dc5c1..bb614d0 100644 --- a/kernel/usermode.c +++ b/kernel/usermode.c @@ -15,6 +15,9 @@ //https://wiki.osdev.org/Task_State_Segment tss_struct sys_tss; //Define the TSS as a global structure +static volatile uint32_t c1; +static volatile uint32_t c2; + void install_tss(int cpu_no){ // now fill each value @@ -28,20 +31,28 @@ void install_tss(int cpu_no){ void userfunc() { + // we need enable here again (since the pushed eflags have it disabled)! x86_sti(); // if we are pid 0, replace ourselves with /bin/init TODO: switch to usermode before! - if(task_get_current_pid()==0)syscall(SYSCALL_EXECVE,BIN_INIT,NULL,NULL); + if(task_get_current_pid()==0) + { + //usermode(&initfunc); + while(1) + { + c2++; + } + } - // kernel worker thread + // kernel worker thread on pid1 if(task_get_current_pid()==1) { + while(1) + { + c1++; + } } } -void switch_to_user_mode() -{ - usermode(&userfunc); -} -- cgit v1.2.3