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]

Re: mutex on atomic variables.


While this is not an eCos question, it is pertinent to many embedded
systems.  When reading or writing to memory is known to be atomic, it
is often possible to omit synchronization.  If the memory accesses can
be either interrupted or split by multiple processors, then you need
to worry.

On the x86 and MIPS processors, a 32 bit aligned memory access is
atomic.  For the most part, you'll need to implement synchronization
for anything longer with some exceptions, see below.

The fact that some memory accesses are atomic can be used to avoid
costly synchronization.  For example, given an interrupt routine that
ets a flag to one when an operation is complete and will not perform
another operation until it is set zero, the main process can check
this value and set it to zero when it is satisfied with the result.
There is no race condition and no need for a synchronization
primitive.

There has been some work done in implementing wait-free data
structures where there no locks and the synchronization is performed
using an alternative scheme.  Their best recommendation requires a
special machine instruction, but the described data structures can be
implemented without it.

  M. Herlihy.
    "A Methodology for Implementing Highly Concurrent Data Structures",
    ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming,
    March 1990, pp.197-206

Cheers

On Sun, Apr 29, 2001 at 04:22:34PM +0000, 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.


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