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?
Page directory
- kataklinger
- Member
- Posts: 381
- Joined: Fri Nov 04, 2005 12:00 am
- Location: Serbia
Re:Page directory
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>
<edit>
If you use one PD for all tasks, there is no memory protection and you must relocate executables.
</edit>
Re:Page directory
Just now I searched the intel's manual.It sayskataklinger 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.
"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?
- kataklinger
- Member
- Posts: 381
- Joined: Fri Nov 04, 2005 12:00 am
- Location: Serbia
Re:Page directory
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.
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.
Re:Page directory
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
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
- kataklinger
- Member
- Posts: 381
- Joined: Fri Nov 04, 2005 12:00 am
- Location: Serbia
Re:Page directory
I didn't say anything about protecting kernel memory. Did I?
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.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.
Re:Page directory
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.<edit>
If you use one PD for all tasks, there is no memory protection and you must relocate executables.
</edit>
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.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.
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.
- kataklinger
- Member
- Posts: 381
- Joined: Fri Nov 04, 2005 12:00 am
- Location: Serbia
Re:Page directory
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.
Oh, my mistake. There's a memory protection between kernel and user space.