Task switching
Posted: Sun Feb 18, 2007 4:29 am
Ok, Well...
My current state : working kernel, software multitasking, paging, syscalls (via an int call), ...
Well it works quite well, however my problem today is how to handle kernel switching without using the guest process' stack ?
Basically when an interrupt happens (preempt current stack, syscall, process crash, ...) I push on the process' stack the registers.
This is bad, if, for example, the process generated a pagefault exception *because* the stack was full (in this case, I should dynamically allocate a new page to let the stack grow a bit more).
I tried on other oses (linux) and even if I mess up the stack (set esp to 0) the exceptions are still handled as expected.
I know that using hardware task switching allows to have the cpu switch directly to a new stack on entering the kernel, but it's also said to be slower and not used anymore in modern oses (as said here).
So, I was wondering which solution exists for that?
I could also decide to have a memory location containing the kernel stack but it doesn't sound like a good idea...
(I'm also trying to have the task run at ring3, after all it just calls a kernel interrupt (syscall), so it shouldn't be hard.
Any help on this matter is welcome.
My current state : working kernel, software multitasking, paging, syscalls (via an int call), ...
Well it works quite well, however my problem today is how to handle kernel switching without using the guest process' stack ?
Basically when an interrupt happens (preempt current stack, syscall, process crash, ...) I push on the process' stack the registers.
This is bad, if, for example, the process generated a pagefault exception *because* the stack was full (in this case, I should dynamically allocate a new page to let the stack grow a bit more).
I tried on other oses (linux) and even if I mess up the stack (set esp to 0) the exceptions are still handled as expected.
I know that using hardware task switching allows to have the cpu switch directly to a new stack on entering the kernel, but it's also said to be slower and not used anymore in modern oses (as said here).
So, I was wondering which solution exists for that?
I could also decide to have a memory location containing the kernel stack but it doesn't sound like a good idea...
(I'm also trying to have the task run at ring3, after all it just calls a kernel interrupt (syscall), so it shouldn't be hard.
Any help on this matter is welcome.