public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] mutex on atomic variables.
@ 2001-04-29  9:22 chaman bagga
  2001-04-29  9:43 ` elf
  0 siblings, 1 reply; 2+ messages in thread
From: chaman bagga @ 2001-04-29  9:22 UTC (permalink / raw)
  To: ecos-discuss

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 .

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] mutex on atomic variables.
  2001-04-29  9:22 [ECOS] mutex on atomic variables chaman bagga
@ 2001-04-29  9:43 ` elf
  0 siblings, 0 replies; 2+ messages in thread
From: elf @ 2001-04-29  9:43 UTC (permalink / raw)
  To: chaman bagga; +Cc: ecos-discuss

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 .

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-04-29  9:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-29  9:22 [ECOS] mutex on atomic variables chaman bagga
2001-04-29  9:43 ` elf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).