trouble with switching page directory
trouble with switching page directory
I was wondering how you deal with switching the page directory and having the stack changed. I noticed a nasty bug when trying to test multitasking. I call switch page directory before changing the register context to do a proc switch, but while calling switch page directory, the stack is changed so when it goes to return from switch page directory, it returns somwhere it shouldnt and eventually crashes.
-
- Member
- Posts: 223
- Joined: Thu Jul 05, 2007 8:58 am
Re: trouble with switching page directory
There are two options basically, make sure that the stack you're using during switching is at the same location in both pagemaps. The other option is to simultaniously do a full stack switch and thus save/restore the stack and base pointers (x86) or whatever their equivalent might be on the architecture you're using.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: trouble with switching page directory
I have a per-processor stack to use when changing address spaces and certain other system settings - you can store the state to the old stack, disable interrupts and switch to the "temporary" stack, change address space, switch to the right stack and enable interrupts, restore the other task's state, resume, profit