This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[Fwd: Re: mutex on atomic variables.]




-------- Original Message --------
Subject: Re: [ECOS] mutex on atomic variables.
Date: Mon, 30 Apr 2001 19:53:30 -0500
From: Ashwin Kamath <kamath@OmegaBand.com>
Organization: OmegaBand Inc
To: chaman bagga <chamanbagga@hotmail.com>
References: <F3LYluLCTaogxLDp7mv000071f1@hotmail.com>

Let's see,

Declaring a variable volatile only excludes it from compiler
optimizations but this
does not imply atomicity. You really need to give more information on
the processor
you are using, because some processors do not provide atomicity for data
access which
are not the same width as the processors data bus. Moreover, some
processors do not
provide atomicity for accesses which are not aligned to the data bus
width of the processor.

The answer also depends on the specific problem that you want to solve.
Some processors 
allow specific read modify write instructions, while others don't. So if
you need to gaurd
your variables in read modify write operations, you will have to
assemble instructions,
if the processor has the ability to do it, for the problem you are
trying to solve. 
The compiler would not use these special 
instructions, because in most cases, the compiler cannot deduce the
programmers intentions. 
Besides, in all optimizations that the compiler does, these instructions
will not figure
because these instructions do not happen to be optimal solutions, in
terms of number of instructions
or number of clock cycles.

Have fun
-Ashwin.

chaman bagga wrote:
> 
> Is is necessary to guard global variables by mutex, particularly if they are
> of type int/short/char and if they have been declared as volatile ?
> 
> [ I know that this question is not directly related to ecos, but that's what
> i'm using :)]
> 
> Thanks and regards,
> Chaman.
> 
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
begin:vcard 
n:Kamath;Ashwin
x-mozilla-html:FALSE
org:OmegaBand Inc
adr:;;;;;;
version:2.1
email;internet:kamath@OmegaBand.com
x-mozilla-cpt:;0
fn:Ashwin Kamath
end:vcard

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]