OSDev.org

The Place to Start for Operating System Developers
It is currently Sun May 19, 2024 4:36 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: What paging method do you use?
PostPosted: Mon Apr 14, 2008 2:04 pm 
Offline

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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 2:01 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2646
Location: Devon, UK
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 2:17 am 
Offline
Member
Member

Joined: Wed Apr 09, 2008 6:57 pm
Posts: 63
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 2:52 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2646
Location: Devon, UK
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 3:20 am 
Offline
Member
Member

Joined: Wed Apr 09, 2008 6:57 pm
Posts: 63
Okay, great. Thanks for that, Adam :-)

Cheers,
Lee


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 17, 2008 3:14 am 
Offline

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 66 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group