Page 1 of 1

questions about paging!

Posted: Thu Oct 04, 2007 10:35 pm
by mohammed
should i map the whole memory from the location 0 to the last address available ? or i should map after the address 0x100000 ?
if i started to map should i map the whole memory or only what the current process need
i mean process1 is the current process then allocate 4 KB for it then map it after the end of the process deallocate the 4 KB and so on for every process
is it better to make one entry for each process ? or should i make one directory and one table for every process ?

Posted: Fri Oct 05, 2007 1:34 am
by JamesM
Oh my good lord did you not get enough answers from the last ten threads you posted?!

Posted: Fri Oct 05, 2007 2:57 am
by mohammed
knowledge seeker never got enough :wink:
specially when he is dumb like me : ( (

Posted: Fri Oct 05, 2007 2:31 pm
by xyjamepa
I think this
and this
might help.

Posted: Fri Oct 05, 2007 9:40 pm
by mohammed
shokraan although i read them before !!

Posted: Sat Oct 06, 2007 11:35 am
by xyjamepa
Hi...

First of all would you please read this
should i map the whole memory from the location 0 to the last address available ? or i should map after the address 0x100000 ?
Let's assume you loaded your kernel at 0x100000,and now you want to enable paging,once you did
all memory addresses you'r working with are virtual,that also apply for your kernel addresses,
here you have to choices:
*Identity mapping
*loading your kernel as higher-half
for the first choice you map the first 4MB from 0 -> 0x400000,here you have to make
physical addresses equal to virtual addresses.

Second choice , the kernel is loaded at 1MB in the physical address space (0x00100000), but is mapped at 3GB + 1MB in the virtual address space (0xC0100000).
and there's an example about that here
if i started to map should i map the whole memory or only what the current process need
i mean process1 is the current process then allocate 4 KB for it then map it after the end of the process deallocate the 4 KB and so on for every process
You give each process page directory entry that means each process has
its own 4Mb of virtual memory.

Posted: Sat Oct 06, 2007 1:00 pm
by os64dev
mohammed wrote:shokraan although i read them before !!
And you still need to ask that question? There is no good solution only the solution that works for you. Keep in mind that trying and failing gives you more knowledge then obtaining a good solution.

Posted: Sat Oct 06, 2007 2:34 pm
by frank
Basically the most common way of doing it is too use 1 page directory and at least 1 page directory for each process. Where you map the pages too is largely up to you. The kernel will end up being mapped into the address space of all processes (for efficiency) so keep that in mind when deciding where too map your kernel too. My kernel for example is a higher half kernel and starts at 0xC0000000. (Start of 3rd GB) My applications on the other hand can be mapped anywhere below 0x80000000.

Posted: Sun Oct 07, 2007 11:53 am
by ManOfSteel
@abuashraf:
Second choice , the kernel is loaded at 1MB in the physical address space (0x00100000), but is mapped at 3GB + 1MB in the virtual address space (0xC0100000).
What the advantage of 0xc0100000? Why not just 0xc0000000?
You give each process page directory entry that means each process has its own 4Mb of virtual memory.
You mean 4GB, don't you?


@frank:
Basically the most common way of doing it is too use 1 page directory and at least 1 page directory for each process.
You mean, you would use more than one page directory? What's the purpose of this since just one can reference the whole 4GB of virtual memory? Is it even possible? Or maybe you only meant page table instead of page directory?

Posted: Sun Oct 07, 2007 12:57 pm
by frank
@frank:
Basically the most common way of doing it is too use 1 page directory and at least 1 page directory for each process.
You mean, you would use more than one page directory? What's the purpose of this since just one can reference the whole 4GB of virtual memory? Is it even possible? Or maybe you only meant page table instead of page directory?
I use 1 page directory per process. That is the only way to insure that one process cannot corrupt the memory of another process.

Each individual process can have as many page tables as it needs.

Posted: Sun Oct 07, 2007 2:10 pm
by JAAman
well, it is possible to give each task multiple page directories -- in fact at least 2 of us do -- we give each thread its own page directory (actually, i currently just modify it, but that might change with my current rewrite...)

its also possible to give each thread its own page directory, but im not sure why you would... if you wanted to give more memory, then you could use banking to accomplish that in a simpler manor (which i support...)

Posted: Sun Oct 07, 2007 6:22 pm
by xyjamepa
ManOfSteel wrote:@abuashraf:
Second choice , the kernel is loaded at 1MB in the physical address space (0x00100000), but is mapped at 3GB + 1MB in the virtual address space (0xC0100000).
What the advantage of 0xc0100000? Why not just 0xc0000000?
If the kernel loaded at 0x00010000 then it will appear at 0xC0010000
Also if your kernel loaded at 0x00100000 then it will appear at 0xC0100000.
so if your kernel loaded at 0x0 the it will apear at 0xC0000000.
but please note if you loaded your kernel at 0x0 physical address you will crash alot of
reseved memory space under 1M such as text screen video memory which is located at 0xB800.

Thanx.

Posted: Sun Oct 07, 2007 6:53 pm
by frank
Not necessarily. You can map your kernel at any address you like. It doesn't matter what physical address the kernel is located at.

Posted: Mon Oct 08, 2007 2:24 am
by mohammed
thanks all i will use the first way to load it at 0x100000 and paging the first 4 MB then every address will refer to the same physical address !
i will make a page directory and page table for every process...