I'm busy implementing handles or something similar for my os. These will be for things like threads, processes, pipes etc.
I'm using some kernel memory that is dynamically allocated to store this info in linked lists. As such, the total number of handles will be divided amongst all applicable 'sections' of my os.
I was wondering what a good number would be. I was aiming for 64k or 32k entries, but I'm not sure if that is realistic. What is the max for windows, linux or any of your oses?
BTW: This is technically my first topic
How many handles? and the associated memory management
- liquid.silver
- Member
- Posts: 46
- Joined: Sat Jun 30, 2007 12:07 pm
- Location: South Africa
- Contact:
How many handles? and the associated memory management
Last edited by liquid.silver on Wed Jul 11, 2007 2:52 pm, edited 2 times in total.
- liquid.silver
- Member
- Posts: 46
- Joined: Sat Jun 30, 2007 12:07 pm
- Location: South Africa
- Contact:
It is a linked list, but the data is not stored in normal memory. The first 4MB of physical memory is reserved for the kernel, VGA etc, and it is mapped into every address space. I want these lists to be stored in here so I have a limited amount of memory that is allocated for this, and as such I will have to impose a limit much smaller than 32-bits. (I'm designing for x86 BTW)
So will me 64k or 32k entries be enough? Or is there a better way to store data that can be accessed from any address space?
So will me 64k or 32k entries be enough? Or is there a better way to store data that can be accessed from any address space?
Yeah, you can reserve a whole range of virtual memory (like 0xC0000000 to 0xFFFFFFFF) for the kernel. Keep a global kernel pagedir up-to-date with your kernel memory allocations. Then, if a process pagefaults (while in kernel mode) with a memory access above 0xC0000000, you can check inside the global directory to see if it's a valid address. If it is, copy the entry or entries from the global directory to the current process's page directory.
- liquid.silver
- Member
- Posts: 46
- Joined: Sat Jun 30, 2007 12:07 pm
- Location: South Africa
- Contact:
That seems like a good idea except what happens if that area gets 'too full' and there is a large amount of page faults? I also don't want a large number of page tables.Yeah, you can reserve a whole range of virtual memory (like 0xC0000000 to 0xFFFFFFFF) for the kernel. Keep a global kernel pagedir up-to-date with your kernel memory allocations. Then, if a process pagefaults (while in kernel mode) with a memory access above 0xC0000000, you can check inside the global directory to see if it's a valid address. If it is, copy the entry or entries from the global directory to the current process's page directory.
As i'm typing this I've realised that i could keep one copy of each page table, and that those could easily be used in each address space directory, so actually i wouldn't be using any extra memory. Actually, after reading your post again, I really didn't understand it fully at first.
Thanx, I think you just help solve a huge collection of problems!