Talk:Ada Programming/Pragmas/Volatile

Volatile variables and Tasking
I've removed the example of a volatile variable used for various tasks. This usage presents several problems, even in uniprocessors. In that case it would be more illustrative to use an atomic variable instead of a volatile one. Although in some architectures the following code is possible (although probably not portable between different compilers):

Shared_Counter : Integer_64; (Shared_Counter);

In architectures like SPARC the compiler would generate instructions that update the doubleword atomically. However, the compiler won't allow you to define the variable as Atomic because in a multiprocessor machine doubleword updates to memory are not guaranteed to be atomic, even if performed by a single instruction. Of course, there is no problem in a uniprocessor machine (and if the compiler generates the adequate object code).

Anyway, using volatile or atomic variables for task communication presents several problems like multiple tasks updating the value, or executing over a multiprocessor or multicore platform. Probably the wikibook should reflect that... doesn't it? &mdash;surueña (talk) 15:48, 28 May 2008 (UTC)

This page has incorrect information. The volatile qualifier from the C language does NOT guarantee atomic access. This is a big misconception.