What paging method do you use?

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
sheena9877
Posts: 16
Joined: Wed Jan 02, 2008 10:44 pm
Location: USA

What paging method do you use?

Post by sheena9877 »

Hi,
I already experimenting different methods of paging.
I tried GDT Trick of Tim Robinson, I have some issues with it, if I include some of my code the , PC resets.
I tried Higher Half kernel without the GDT Trick, I was stucked in the same problem like the first method.
But when I tried the Identity mapping, it works fine.
My kernel is loaded at physical address 100000h, and I identity mapped starting from address 0 up to the available memory.
My question, is Identity mapping technique logically good that I can produce a Windows-like OS? Or will I suffer some technical problem in the long run and fail on this project?
What method do you use in your OS?

Thanks,
Sheena
BY THE TIME YOU FINISH YOUR OS, OS IS ALREADY OBSOLETE
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

The time you will hit problems is once you start multitaskng. The reasons for this are twofold:

1) You may want to link process A at 0x100000 and also link process B at 0x100000. If you have separate memory spaces per-process, this is entirely possible. If not, you either have to ensure that each binary is run from a different location in memory (every app designer needs to know where every other app designer has linked their applications!) or use position independent code for each binary. If you do this, you are limited to one memory space containing the heap, stack and binary data for every application.

2) Memory protection. Eventually, you will probably want a separate PD (in 32 bit mode) or PML4 (in 64 bit mode) for each task. This means that any process can only see its own data, protecting the other processes from erroneous / malicious memory accesses.

My suggestion would be to place your kernel at around the 3GB mark in virtual RAM (if you are in 32 bit PMode) and for now, do not use the space under this. Space up to 3GB will eventually be your 'application space' and space above 3GB will be kernel space. You will probably then want separate paging structures for each process.

Cheers,
Adam
zerosum
Member
Member
Posts: 63
Joined: Wed Apr 09, 2008 6:57 pm

Post by zerosum »

Hi AJ,

I've seen mention somewhere else that many kernels locate themselves in the upper end of virtual memory, just as you've suggested above.

What is the reason for this?

If the kernel is loaded into physical memory at 0x100000, why not just identity map that part of it and leave the higher memory for applications?

Cheers,
Lee
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

Absolutely no reason why you can't do that. However, if your OS gets to the point where others are creating apps for it, they will all need to know that they should link their apps at a high address (no so conventional).

Linking kernels at a high address is perhaps just a psychological way of getting the kernel 'out of the way' of user apps. In much the same way, you could say that all user apps will start at 0x00000000, but this would mean that you have no 'NULL pointer trap' - for this reason, some OS's seem to get user apps to start at 0x100000, for example.

Cheers,
Adam
zerosum
Member
Member
Posts: 63
Joined: Wed Apr 09, 2008 6:57 pm

Post by zerosum »

Okay, great. Thanks for that, Adam :-)

Cheers,
Lee
sheena9877
Posts: 16
Joined: Wed Jan 02, 2008 10:44 pm
Location: USA

Post by sheena9877 »

I am doing more experiments, it looks like paging by Identity is the best.

Thanks anyhow.
Sheena
BY THE TIME YOU FINISH YOUR OS, OS IS ALREADY OBSOLETE
Post Reply