Tasks

Task (User) Stack

Each task has its own stack so as to properly support multitasking. When you create a task via REXIS_CreateTask, you supply the stack size for the task. For most tasks, you can use the define REXIS_MIN_STACKSIZE, which is currently set to 640 bytes [2]. You can also specify 0 for the stack size, whereupon the kernel will use the default stack size. Keep in mind that during a context switch, the task’s CPU state (which is at least 16 32-bit CPU registers, or 64 bytes) must be saved; plus there is other exception overhead.

If your task function has heavily nested function calls, or if the task function and the functions it calls have a lot of local variables, then you will need to increase the stack size. Note: the library function printf uses a lot of memory; so especially if you use floating point expressions, you should add about 500 to 1000 bytes to the stack size if the task function uses printf.

A future release of REXIS will include tools to modify the firmware image to set the stack size values to be the optimal values by using call tree analysis. This will only work for REXIS_TaskCreate calls with 0 for stack size argument.