How many handles? and the associated memory management

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
User avatar
liquid.silver
Member
Member
Posts: 46
Joined: Sat Jun 30, 2007 12:07 pm
Location: South Africa
Contact:

How many handles? and the associated memory management

Post by liquid.silver »

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 ;)
Last edited by liquid.silver on Wed Jul 11, 2007 2:52 pm, edited 2 times in total.
Andrew275
Member
Member
Posts: 30
Joined: Tue Feb 27, 2007 2:29 pm
Contact:

Post by Andrew275 »

Since you're using a linked list, you can pretty much support an "unlimited" number (of course you'll run out of memory and address space).
My operating system: Desktop OS
Content management system/forum: Deluxe Portal
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Where it makes sense, I try to limit the amount of handles to register/hardware limits (i.e. 32 bits, 4 billion)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
liquid.silver
Member
Member
Posts: 46
Joined: Sat Jun 30, 2007 12:07 pm
Location: South Africa
Contact:

Post by liquid.silver »

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?
Andrew275
Member
Member
Posts: 30
Joined: Tue Feb 27, 2007 2:29 pm
Contact:

Post by Andrew275 »

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.
My operating system: Desktop OS
Content management system/forum: Deluxe Portal
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Well right now with only a few applications open my task manager says that there is 21503 handles open.
User avatar
liquid.silver
Member
Member
Posts: 46
Joined: Sat Jun 30, 2007 12:07 pm
Location: South Africa
Contact:

Post by liquid.silver »

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.
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.

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. :D 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! :D
Post Reply