Page directory

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
raywill

Page directory

Post by raywill »

Can I use one page directory for all my program and task,or one page for each task?
Or both are OK?in this case,which is better?
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Re:Page directory

Post by kataklinger »

If you use different PDs for all tasks you will prevent one task to change something that belongs to the other task. And tasks can begin on same address, so you don't need to relocate it.

<edit>
If you use one PD for all tasks, there is no memory protection and you must relocate executables.
</edit>
raywill

Re:Page directory

Post by raywill »

kataklinger wrote: If you use different PDs for all tasks you will prevent one task to change something that belongs to the other task. And tasks can begin on same address, so you don't need to relocate it.

If you on PD for all tasks, there is no memory protection and you must relocate executables.
Just now I searched the intel's manual.It says

"Memory management software has the option of using one page directory for all programs and tasks ,one page directory for each task ,or some combination of the two."

Any idea towards this?
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Re:Page directory

Post by kataklinger »

You can have for instance 7 tasks, first three task shares on PD, and the other four has separate PDs for each task.

But if you want to share memory between tasks it si better to map one or two (or more) pages in both task's PDs.

Thread of one process use usually share same PD.
OZ

Re:Page directory

Post by OZ »

You can't say, that using only one page directory will prevent you explicitly from protecting kernel space and user space or individual tasks from each other.
You may have one page dir and can mark some part of the page tables to be accessable by ring 3 and reserve another part for the kernel.
All you would have to do is implement some mechanism, that changes the page tables according to a record of your paging information that is associated with the process upon task switch and the bookkeeping itself of course.

On the other hand using seperate page dirs and page tables will minimize the workload of a task switch.
It depends on your priorities - speed or less memory usage
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Re:Page directory

Post by kataklinger »

I didn't say anything about protecting kernel memory. Did I?
All you would have to do is implement some mechanism, that changes the page tables according to a record of your paging information that is associated with the process upon task switch and the bookkeeping itself of course.
That's excatly what happens when you change PD (and when you mark kernel's pages as global). It's like software PD switching, it is slower and more complicated.
OZ

Re:Page directory

Post by OZ »

<edit>
If you use one PD for all tasks, there is no memory protection and you must relocate executables.
</edit>
Well, actually you did say that there's no memory protection and and I answered that this isn't neccessarily a consequence of just using one page dir.
That's excatly what happens when you change PD (and when you mark kernel's pages as global). It's like software PD switching, it is slower and more complicated.
It is not the same - perhaps I expressed myself unclear - I mentioned the possibility of using one page dir and one memory area for the page tables. The actual paging information resides on the heap and the page tables are edited upon task switch.

Just switching page dirs requires several individual memory areas that are used for the processes different page tables (apart from shared areas you mentioned of course).
By just switching the page dir (aka changing the value of cr3) you just change the addresses of already existant page dirs / page tables there takes no editing place.

It's more like software page table switching aslong as you always use the same address space layout.

You're definetely right, that this will be slower than just changing cr3 but as he asked if it would be possible, I just pointed out that it is. As I already mentioned it's up to him what he appreciates - speed or less memory usage.
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Re:Page directory

Post by kataklinger »

OZ wrote: Well, actually you did say that there's no memory protection and and I answered that this isn't neccessarily a consequence of just using one page dir.
:o
Oh, my mistake. There's a memory protection between kernel and user space.
Post Reply