Pumpkin, Inc.

Pumpkin User Forums

Volatile global variables

If you can't make Salvo do what you want it to do, post it here.

Volatile global variables

Postby peden » Sun Feb 06, 2011 8:27 am


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)

Posts: 7
Joined: Fri Jan 30, 2009 12:00 am
Location: Denmark

Re: Volatile global variables

Postby aek » Mon Feb 07, 2011 1:43 pm

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.
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Return to Coding

Who is online

Users browsing this forum: No registered users and 3 guests