Task local variables

pni wrote on Monday, November 24, 2008:

Hi

My question:
if i use a lot of local variables in a taskA - i.e. some of them are in CPU registers and some are put on the stack (thats how memory normally are allocated).

Now a higher priority taskB preemtives taskA and do some job and returns control to taskA.

When taskA runs again are all local variables valid or do i have to declare them static - i asume them in Cpu regs. are restored but what about the local vars. which where stored on the stack in taskA ???

hooverphonique wrote on Monday, November 24, 2008:

yes, all registers are saved on the stack before a context switch and restored afterwards, so your vars will be intact…