Task Switching Page Dir

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Task Switching Page Dir

Post by Nessphoro »

So guys I've got a problem, every time I load a task, shared page directory is created that will be used with all threads,
A threads gets it's own registers stacks, page directory, etc.
Now Thread's stack starts @ 0xBFFFFFFF (Doesn't really matter) and I create a page for it, but when this thread tries to create a new page directory, it is as if I write to the same stack( Because this thread gets corrupted and the other is never called, I've actually checked), but if I change so that each thread gets it's own address(0xBFFFEFFF, for example) everything is fine, to an extent.

Any help on how to properly, link page directories + copy the data into the new directory without corruption.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Task Switching Page Dir

Post by gerryg400 »

I'm assuming that your OS has a 3G/1G split (that apps are each from 0 -> 0xbfffffff and the kernel from 0xc0000000 -> 0xffffffff). And that the stack you refer to at 0xbfffffff is the user stack of the process. I'm also assuming that you have kernel stacks safely in the kernel area.

If this is true then each process needs its own pgdir. Because the kernel will appear in the upper 1G of each memory context, the top 256 pgdir entries (from pgdir[768] to pgdir[1023] will be identical for all processes. The first 768 entires (from pgdir[0] to pgdir[767]) will be (unless you are sharing memory) different for each process.

BTW, in your post you said that each thread gets its own pgdir. It's more usual to define the thing that has a separate pgdir as a process. So all the threads within a process need to have separate stacks at separate addresses (both virtual physical) referred from that single pgdir.
If a trainstation is where trains stop, what is a workstation ?
Post Reply