Page 1 of 1

Volatile global variables

PostPosted: Sun Feb 06, 2011 8:27 am
by peden

Should global variables that can be accessed by two or more tasks be declared as volatile?
Or is this only necessary for a preemtive RTOS, and not a co-operative one like Salvo?

(I'm using Salvo Pro 4.2 for AVR with the IAR EWAVR 5 compiler)


Re: Volatile global variables

PostPosted: Mon Feb 07, 2011 1:43 pm
by aek
Salvo is not preemptive, so the usual mechanism for protecting access to a shared variable -- which is an issue in preemptive systems, because task preemption occurs based on interrupts -- is not an issue when we are concerned with two tasks accessing a shared variable.

Shared variable access based on interrupt sources is of course still an issue, just like it would be in a non-RTOS application where e.g. an ISR and some mainline code both access a shared global variable.