Hi
I am using the new CMSIS-RTOS and seem to have a stack problem that I don't understand. In order to create even the simple of task (one that just polls a CAN interface) that will not cause a hard fault when created I cannot use a default thread stack size of 512 or even 4096. I have to declare a user stack size of 8000 bytes just to keep it from causing a hard fault when it is created.
Since the thread itself does not require hardly any memory at all, I assume it is the RTOS that requires the memory in order to start the thread. It does not make any sense to me why so much memory is needed.
I have had to declare user stacks for all of my threads in order to get them created without a hard fault. The system works fine if I do this.
Unfortunately I want to use 14 threads so I cannot continue to use this "work around" or avoid figuring out why the threads need such large stack sizes. This is because there apparently is a limit as to the number of user defined stacks.
Error: "too many threads with user-provided stack size"
My simple thread does not use any buffers and just a few local ints I cannot blame the threads themselves in that they are using too much memory. There is something more central that is causing this minimum of 8000 bytes for me to create a task.
I just cannot figure out what setting or whatever is causing the RTOS to want so much memory.
Does anyone have any ideas as to what I must have set up wrong in RTX_Conf_CM.c or what might be the cause of this per thread memory?
I am trying to learn RTX. I have some example code from the M0 book by Yui. Every thing I see in the examples is about TASK and not thread. I took a search for size. one thing I saw was the statement
C:\Keil_v5\ARM\RV31\INC\RTL.h(220) :
#define os_sys_init_user(tsk,prio,stk,size)
Also
C:\Keil_v5\ARM\RV31\INC\RTL.h(126) : #define os_sys_init_user(tsk,prio,stk,size)
RTX Config C file // <o>Task stack size [bytes] <20-4096:8><#/4> // Set the stack size for tasks which is assigned by the system. // Default: 200 #ifndef OS_STKSIZE #define OS_STKSIZE 50 #endif
this one uses the default stack size defined in rtx.h
#include <rtl.h>
OS_TID os_tsk_create ( void (*task)(void), /* Task to create */ U8 priority ); /* Task priority (1-254) */
http://www.keil.com/support/man/docs/rlarm/rlarm_os_tsk_create.htm
I think the rtx.h is really supposed to be RTL.h.
If you open RTL.h and look there is a config wizard and on my examples from the book the size of task stack size was 200 bytes.
Gary
\
Thanks for your thoughts on this. I am using the new CMSIS-RTOS and not RTX. RTX is the older version.
I did find that I can increase the number of tasks that can have user defined stacks to up to 250 by editing the OS header file. It allows me to continue as I was without diving into why so much memory is required just to make a simple task.
As long as I still have RAM left of course.
Hi Steve,
Did you ever find out what caused the high stack usage? It looks like I'm having the same problem.
I'm now trying to use the user-provided stack size configuration, but no luck yet. Still getting Hard faults.
Dirk