Specify per project stack size?

Post Reply
PeterM
Posts: 9
Joined: Fri Feb 08, 2008 9:34 pm
Location: Edinburgh, UK
Contact:

Specify per project stack size?

Post by PeterM » Sat Feb 09, 2008 1:07 am

To cater for Quake's hefty stack requirements I've had to increase the stack from 128K to 256K. It used to be 512, but I did some optimisation in R_RecursiveWorldNode to take the usage down.

I was wondering if there is a way to do this on a per .elf basis instead of modifying the global ogc.ld linkscript?

Thanks!

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Specify per project stack size?

Post by WinterMute » Mon Feb 11, 2008 5:21 pm

That might be a useful feature to have actually.

You can adjust the stack size per thread using LWP_CreateThread though and, fwiw, the main function in a libogc app is actually the first thread started by the microkernel.

So, something like this will let you manage the stack size in your code.

Code: Select all

static lwp_t hmain_game = (lwp_t)NULL;

int main()
{

	...
	
	setup code
	
	...
	
	LWP_CreateThread( /* thread handle */ &hmain_game, /* code */ main_game, /* arg pointer for thread */ NULL, /* stack base */ NULL,  /* stack size */ 512*1024, /* thread priority */ 50);
	LWP_SetThreadPriority(0,0);

	while(1);
}

static void* main_game(void *arg)
{
	...
	
	interesting stuff
	
	...

}
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 11 guests