Data types

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
paulbarker

Data types

Post by paulbarker »

I'm currently trying to implement the basic data types I need to build my OS and specifically my new physical memory manager. I have got the basic ideas and code for bitmaps, lists and multi-level tables.

Now, consider a large system running on an X86. Giving the kernel 1GB of virtual memory leaves 3GB for user processes, but means that with todays amounts of memory, it is very likely that not all memory can be mapped at once. Using simple pointers, I would be pretty limited in where I can store my kernel data structures (such as lists), since each element in the list would have to have a constant virtual address.

Say I map the first 512MB at 3GB to 3.5GB, leaving 512MB for dynamic kernel mappings. This seems quite reasonable, but does limit the area for which virtual addresses will be constant. I don't think it's sensible to map an element of a list in the dynamic area (above 3.5GB) since that will eat into virtual memory which may have better uses.

I'm trying to decide if I should convert my data structures to work with physical addresses, since the actual addressing will all be handled internally within the data structure methods. The problem is these physical addresses will have to be 36-bit to cope with PAE or whatever its called. I don't want to use 64-bit physical addresses when only 36-bits are in use, and my only other choice is to use an array of 5 chars, which destroys any hope of execution speed.

I'm a little confused at the moment and need to let these things sink in. I'm just looking around for any ideas or bits of advice, if anyone can tell me how they handled their data structures?

Thanks in advance,
Paul Barker
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:Data types

Post by Colonel Kernel »

I've been using virtual addresses everywhere, but not constant ones. Why would you need constant ones?

Are you talking about kernel data structures in general, or memory management structures in particular?
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
paulbarker

Re:Data types

Post by paulbarker »

In a list, each element has a pointer to the next. If the next element moves by being unmapped and later mapped at a different address, the pointer to it is no longer valid. I'm trying to decide if I should keep everything mapped in the same place when in use or allow this.

The advantage comes in being able to unmap structures in use by process X when process Y is running but X is still in memory.

As I said, I need to think about how much of an advantage that really is. It could be a pointless excersize, or it may be worthwhile. I'm just trying to get some input.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:Data types

Post by Colonel Kernel »

If you're talking about data structures in kernel space, I see little reason to unmap them at all... I see even less reason to re-map them to a different virtual address if you unmap them. I was planning to keep all per-process kernel bookkeeping structures physically resident all the time, and mapped virtually to the same place.

Are you just trying to conserve kernel virtual address space? Maybe you can dedicate a chunk of the kernel virtual address space to per-process structures (as long as you don't need to see more than one of those structures at a time, since otherwise you'll have to keep switching address spaces).
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
paulbarker

Re:Data types

Post by paulbarker »

I think it's just me being overambitious, as usual. If I design my data structures properly, internal things like this should be changeable without affecting the interface presented to the rest of the kernel. I think for now I'll just go for basic pointers and have everything mapped when it is in use.
Post Reply