This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

  • TI Thinks Resolved

RTOS/CC1310: Static Variables in RTOS Tasks

Intellectual 805 points

Replies: 1

Views: 2551

Part Number: CC1310

Tool/software: TI-RTOS

Is there a reason you would not declare task variables as static?

I'm guessing when you statically create the thread the variables are static themselves?  (I noticed their values persist like they are static, ie. if you increment a counter in a task the value persists).

If you terminate a task, if you declare the variables static will they persist outside the now terminated task?  

Are the task variables limited in the task scope only without the static declaration?

Is there anything in the RTOS I should consider for static declarations of variables with TI-RTOS? 

I haven't seen much in the SYS-BIOS manual regarding this scope / and existence of variables.  Most TI examples don't declare the task variables  as a static (some do though I think... 50/50).

  • The variables not declared as static in a stack are allocated on the Task stack and are available only in the task context. The memory allocation of such variable are deleted on a Task_delete() or Task_destruct(). The scope of the variables declared as static in a Task is limited to the task. It does not make sense to persists its value after task deletion and also tasks are not re entrant. If you want the value of a variable to persists, then you may want to declare it as a global. To its usage with respect to the CC devices, I personally do not see any advantage of declaring a static variable with in a task context (I may be wrong here). Local static declarations makes more sense for functions and not so much for tasks in my opinion.

    This is more of a TIRTOS question than CC1310. Will move it to the right forum. You will get better answer there :)

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.