kernel heap size

Post Reply
kazzmir
Posts: 3
Joined: Tue Oct 18, 2011 8:06 am

kernel heap size

Post by kazzmir » Fri Dec 02, 2011 1:19 am

I have discovered that the initial kernel heap size is too low for my needs. In libogc/system.c is

#define KERNEL_HEAP (1*1024*1024)

If I adjust this size to 2mb (change 1 to 2 there) then my program works. The underlying issue is I create too many threads with a large stack size, 128kb. The stack is allocated from the heap/workspace thing which is the same size as the kernel heap. 1mb / 128kb is roughly 8, so if you subtract a handful of other objects that already use the kernel heap that leaves 7 threads. My program runs into this limit and fails.

I don't actually needs 128kb, that is just an upper limit to make me feel safe. The actual limit I need is somewhere between 64kb and 128kb but I am not happy about trying to figure out exactly how large to make it. If I make it to small then the program will ultimately crash in some other place.

Would it be possible for SYS_Init() to accept a u32 which defines the kernel heap size? Possibly there could be an extra function to preserve backwards compatibility, SYS_Init_Heap(), which SYS_Init can call with KERNEL_HEAP.

tueidj
Posts: 40
Joined: Thu Dec 10, 2009 9:26 am

Re: kernel heap size

Post by tueidj » Sun Dec 04, 2011 6:21 pm

Why not allocate the stack space for the threads yourself?

kazzmir
Posts: 3
Joined: Tue Oct 18, 2011 8:06 am

Re: kernel heap size

Post by kazzmir » Mon Dec 05, 2011 7:53 pm

You are right, I should do that. I did not inspect what the 'stackbase' argument was used for carefully enough.

Post Reply

Who is online

Users browsing this forum: No registered users and 60 guests