[Geekos-devel] Project 2 Question
Status: Pre-Alpha
Brought to you by:
daveho
From: <wm...@ao...> - 2008-06-18 17:06:31
|
In this function: void Switch_To_User_Context(struct Kernel_Thread* kthread, struct Interrupt_State* state) { ??? /* ???? * Hint: Before executing in user mode, you will need to call ???? * the Set_Kernel_Stack_Pointer() and Switch_To_Address_Space() ???? * functions. ???? */ ??? TODO("Switch to a new user address space, if necessary"); } the kernel stack pointer should be set to the top of the stack as follows: Set_Kernel_Stack_Pointer(((ulong_t) kthread->stackPage) + PAGE_SIZE)); I first saw this done here: http://www.cs.iitm.ernet.in/~cs313/projects/index.html It did not make sense to me because I was worrried about the process stack being corrupted. Then it hit home that there are 2 stacks. Each user process has one stack for use by the kernel on behalf of the process and one mapped into the data segment of the process for use by the code contained in the exe. |