questions about paging!

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
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

questions about paging!

Post 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 ?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Oh my good lord did you not get enough answers from the last ten threads you posted?!
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

Post by mohammed »

knowledge seeker never got enough :wink:
specially when he is dumb like me : ( (
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Post by xyjamepa »

I think this
and this
might help.
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

Post by mohammed »

shokraan although i read them before !!
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Post 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.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post 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.
Author of COBOS
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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.
User avatar
ManOfSteel
Member
Member
Posts: 60
Joined: Tue Feb 01, 2005 12:00 am

Post 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?
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post 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...)
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Post 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.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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.
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

Post 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...
Post Reply