Are KOS limiting stacksize that can be used by my application to some explicit value?
Or it's just increased each time I enters a new function?
I'm talking about stack for automatic (function scope) variables.
How many memory we have for static variables?
Stacksize in KOS
- RyoDC
- Mental DCEmu
- Posts: 366
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Wed Mar 30, 2011 12:13 pm
- Has thanked: 2 times
- Been thanked: 0
- BlueCrab
- The Crabby Overlord
- Posts: 5666
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: Stacksize in KOS
Each created thread has a stack size of THD_STACK_SIZE (which is defined in kernel/arch/dreamcast/include/arch/arch.h), and defaults to 32768 bytes in relatively recent versions (anything from the Git repository, and for a while back from the SVN as well) of KOS, and is allocated from the heap at thread creation time.
The main kernel thread does not have any explicit limit on the stack size, and will simply grow down until it hits the heap (at which point, when you try to allocate memory from the heap, you will get a failed assertion). So, unless you're using threads, there is no explicit limit on the amount of stack space you have.
If you have some reason to change the default of 32768 per normal thread, you can change the #define in that file. One word of warning: do not make it less than 16384 or so if you plan to do anything with files. The realpath function uses more than 8k of stack space, and it gets called by pretty much every single open/fopen/fs_open call.
The main kernel thread does not have any explicit limit on the stack size, and will simply grow down until it hits the heap (at which point, when you try to allocate memory from the heap, you will get a failed assertion). So, unless you're using threads, there is no explicit limit on the amount of stack space you have.
If you have some reason to change the default of 32768 per normal thread, you can change the #define in that file. One word of warning: do not make it less than 16384 or so if you plan to do anything with files. The realpath function uses more than 8k of stack space, and it gets called by pretty much every single open/fopen/fs_open call.