[Tinyos Core WG] volatiles in scheduler
John Regehr
regehr at cs.utah.edu
Thu Jul 10 13:16:39 PDT 2008
I believe the volatile can be removed safety (since the variables do not
race).
John
Philip Levis wrote:
>
> On Jul 3, 2008, at 1:14 PM, John Regehr wrote:
>
>> I took a quick look at the volatile variables in SchedulerBasicP and I
>> believe that the volatile qualifiers are not needed.
>>
>> Motivations for removing these would be (1) cleaning up the code (2)
>> saving a few bytes of code memory and a few cycles (3) patching a
>> bandaid over one of the safe tinyos compiler warnings.
>>
>> Probably now is not the time but perhaps I'll remove these after 2.1.
>>
>> Just as a note: ever since David added compiler barriers to
>> nesc_atomic_start/end there are only three valid reasons to use volatile
>> in TinyOS:
>>
>> - to prevent the compiler from caching racing variables in registers
>> (this is never a problem for non-racing variables)
>>
>> - accessing HW registers
>>
>> - (very occasionally) in library code to avoid potential warnings if a
>> client of the library passes a volatile-qualified argument
>
> John,
>
> You said you looked into this and found removing the volatiles was not a
> problem? I ask because removing them would allow safe TinyOS to avoid a
> warning from casting away volatile.
>
> Phil
>
More information about the Tinyos-2.0wg
mailing list