Memory management design

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
uzytkownik
Posts: 14
Joined: Sat Nov 15, 2008 3:39 pm

Memory management design

Post by uzytkownik »

Hello. I'm starting with OS Dev. I'm planning to write a microkernel. I have some ideas about mm but I'm afraid that when I'll be implementing multitaking it will be a bit too late to make significant change (or rather - I'd prefere to know that before).

Paging
1. Internal (for kernel) API
More or less those methods (I decided to have pseudo-object structures) - adding rings/access rights should be simple:
- get_page_size
- allocate (where, size) - allocates size pages starting at [virtual address] where (-1 if anywhere)
- fake_allocate (where, size, callback) - allocates dummy size pages at where. On access call callback
- release (page) - release a page
- lookup (address) - returns hardware and/or kernel address of address
- rlookup (hwaddress) - returns address in pagetable (NULL if not existing) of kernel/hardware address
- map (page, to) - map page (in hardware/kernel addresspace) to to address (any if to == -1)

2. Implementation (for x86)
The addresspace for kernel is identity of hardware memory (done in 4mb pages). Since it is suppose to be microkernel I don't think that I'll have much swapping of kernel memory.
The rest is 'traditional' v. memory.
Second question is do I need to have the same mapping of the part of memory (code for switching tasks) or TSS will handle it?

Allocation
I've read a few pages about memory management. However I get little information about SLAB allocations. Is it suitable for newbie or should I choose something simpler first?

Sorry for asking those, probably basic, questions - but I STFW (reading till n'th page in google) and I found little at this topics.
User avatar
AndrewAPrice
Member
Member
Posts: 2306
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Memory management design

Post by AndrewAPrice »

I looks good! I would suggest having two allocate functions, one for allocating a page in the kernel memory, one for allocating a page in the user mode section.

And as for memory allocators, I recommend porting liballoc (it only requires 2 hook functions (the lazy way) or 4 hook functions (to implement a lock)).
My OS is Perception.
Post Reply