Process Stack Size

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
pacoblackxx
Posts: 10
Joined: Sat Mar 10, 2012 6:49 pm

Process Stack Size

Post by pacoblackxx »

Hi,

i saw the definitions below in the assembly file

main_stack_size EQU 0x00000400
00034
00035 ;// <h> Process Stack Configuration
00036 ;// <o> Process Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
00037 ;// </h>
00038 proc_stack_size EQU 0x00000400
00039
00040 ;// <h> C-runtime heap size
00041 ;// <o> C-runtime heap size (in Bytes) <0x0-0xFFFFFFFF:8>
00042 ;// </h>
00043 heap_size EQU 0x00000400

Is there any restriction for the process stack size?
I mean, < proc_stack_size EQU 0x00000400> means that the THD_WA_SIZE must be less than 1024bytes? (if the assembly file remain as-is)
can i use a bigger size?for example 4k.

main_stack_size EQU 0x00000400 : this is the stacksize of the main?
heap_size EQU 0x00000400 : and this the heap for the whole program?

thanx
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Process Stack Size

Post by Giovanni »

Hi,

The "process stack size" affects *only* the main() thread stack, other threads have their own stack and it is unrelated to that setting, you can increase it if your main() thread requires more stack.

The heap size is the C-runtime heap, the one used by the compiler for malloc() etc, it is unrelated to the OS heap.

Giovanni
pacoblackxx
Posts: 10
Joined: Sat Mar 10, 2012 6:49 pm

Re: Process Stack Size

Post by pacoblackxx »

If main() calls 4 threads, with 1kb stack each, should i set the main stack to 4kb? (99.9% no, but i am asking)

Also, FATfs has in the ff.h the code below:
#if _FS_REENTRANT
_SYNC_t sobj; /* Identifier of sync object */
#endif

what value should we define for the _SYNC_t?
the default is:
#define _SYNC_t HANDLE
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Process Stack Size

Post by Giovanni »

No :-)

FatFS has already been ported, see the current implementation.

Giovanni
pacoblackxx
Posts: 10
Joined: Sat Mar 10, 2012 6:49 pm

Re: Process Stack Size

Post by pacoblackxx »

yes i know that it is ported, but when i set _FS_REENTRANT to 1 into ffconf.h, i get compilation errors( etc winsect in not a field of FATFS..)

or that chHeapFree() has too many arguments .

you have chHeapFree(NULL, mblock); instead of chHeapFree(mblock) in ff_memfree

you have to define _SYNC_ as Semaphore* i guess
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Process Stack Size

Post by Giovanni »

I will look into that problem when merging the latest FatFS.

Giovanni
Post Reply