atomic operation

  • Permalink
  • submit to reddit
  • Email
  • Follow


Hi,

 Is it official to say that fetching and storing a 'long' (for 32-bit
and 64-bit) is an atomic operation ?

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply guy 10/29/2004 2:33:59 PM

See related articles to this posting


"Guy" <guy.peleg@gmail.com> wrote in message
news:f4d01807.0410280800.4c62b16a@posting.google.com...

>  Is it official to say that fetching and storing a 'long' (for 32-bit
> and 64-bit) is an atomic operation ?

absolutely not.



      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Reply Balog 10/31/2004 10:51:54 AM

guy.peleg@gmail.com (Guy) wrote in message 
news:<f4d01807.0410280800.4c62b16a@posting.google.com>...
> Hi,
> 
>  Is it official to say that fetching and storing a 'long' (for 32-bit
> and 64-bit) is an atomic operation ?
> 

No

joshua lehrer
factset research systems
NYSE:FDS

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply usenet_cpp 10/31/2004 10:54:22 AM

Guy wrote:
> Hi,
> 
>  Is it official to say that fetching and storing a 'long' (for 32-bit
> and 64-bit) is an atomic operation ?
>   peri
There's no C++ concept of atomic operations.   You'll have to
check your particular implementation for such support.

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply Ron 10/31/2004 10:54:43 AM

On 29 Oct 2004 10:33:59 -0400, guy.peleg@gmail.com (Guy) wrote in
comp.lang.c++.moderated:

> Hi,
> 
>  Is it official to say that fetching and storing a 'long' (for 32-bit
> and 64-bit) is an atomic operation ?

No, it is not.  Accesses of the type 'sig_atomic_t', defined in
<csignal> or <signal.h> are guaranteed to be atomic operations.  In
theory this could be an 8-bit type on 8-bit processors, but there
isn't much C++ activity on 8-bit processors these days.

In most cases it is signed or unsigned int, but there is no guarantee.

-- 
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply Jack 10/31/2004 11:16:03 AM

On 29 Oct 2004 10:33:59 -0400, Guy <guy.peleg@gmail.com> wrote:

>  Is it official to say that fetching and storing a 'long' (for 32-bit
> and 64-bit) is an atomic operation ?

I presume, you are talking atomic with regards to threads, right?

If so, then no, it's not. There are too many processor dependent factors  
involved.

On processors that work with aligned data only it's atomic only when  
reading and writing a machine word on machine instruction level, that is,  
the instruction is atomic and can't be interrupted in the middle. For 32  
bit processors the machine word is most likely also a 32-bit int. On  
processors which do work with unaligned data (like x86 does), it's only  
atomic when accessing properly aligned data.

But the machine instruction level atomicity buys you little in multithread  
code. The reason being memory visibility, that is, instruction atomicity  
does not imply that a written to memory value will immediately be seen by  
other threads on a multiprocessor, which is pretty much what you want.  
This is because all modern processors cache memory, writes go to cache,  
cache gets flushed to memory at arbitrary from code's point of view  
moments, other processors may know of the new value only when it has been  
written to memory. So, there must be a means to flush writes to memory and  
to signal other processors to update their cashes. This means are provided  
by memory barriers, that ensure that the effect of invoking them is that  
all other threads will see changes to memory made before invoking the  
memory barrier.

Operating systems provide memory barriers as function calls. For POSIX you  
can find a list of functions that issue the memory barrier here  
http://groups.google.com/groups?selm=opsf9kv0mjti5cme%40localhost.localdomain&rnum=2&filter=0.  
For win32 you may start looking here  
http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/synchro_88127404-a394-403f-a289-d61c45ab81d5.xml.asp


-- 
Maxim Yegorushkin

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply Maxim 10/31/2004 11:18:33 AM

Maxim Yegorushkin wrote:
[...]
> Operating systems provide memory barriers as function calls. For POSIX you
> can find a list of functions that issue the memory barrier here
> 
http://groups.google.com/groups?selm=opsf9kv0mjti5cme%40localhost.localdomain&rnum=2&filter=0.

In addition to the links I've posted in my previous message, see
also <http://cmc.rice.edu/docs/docs/Adv1999Mar1RecentAdva.pdf>.

regards,
alexander.

P.S. DRB it totally wrong with respect to {non}conformance of
release consistency model, BTW.

--
"The current POSIX memory model is far from perfect. [...] I 
 really think you'd be far better off persuing this at the C++ 
 language level and lobbying for a language threading model that 
 can coexist with (carefully designed) POSIX implementations but 
 is not directly dependent on the POSIX language."

   -- DRB (sorta annoyed by pseudo-C++ illustrations ;-) )

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Reply Alexander 11/2/2004 9:38:33 PM

Jack Klein wrote:
[...]
> >  Is it official to say that fetching and storing a 'long' (for 32-bit
> > and 64-bit) is an atomic operation ?
> 
> No, it is not.  Accesses of the type 'sig_atomic_t', defined in
> <csignal> or <signal.h> are guaranteed to be atomic operations.  

Only with respect to assignments in signal handlers (when this
or that signal is delivered to the same thread and only for static 
volatile sig_atomic_t objects). It has really nothing to do with 
threads (just in case you meant to imply that) Uhmm, see 
<http://tinyurl.com/5zvyj>. Better read this entire thread 
<http://tinyurl.com/5g6pm>... you might as well contribute. ;-)

regards,
alexander.

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply Alexander 11/2/2004 9:40:03 PM

Thanks but I think I need to rephrase the question. 

Suppose I have a 'long'(in either 32-bit or 64-bit) I have a process
with two threads. One is reading this 'long' and one is writing it. Is
it possible that while the writing thread is in the middle of the
writing, the process will switched to the reading thread? Or is it
true to say that this action (updating or reading) this long is safe?

Alexander Terekhov <terekhov@web.de> wrote in message news:<4187AF6B.E09C3A11@web.de>...
> Maxim Yegorushkin wrote:
> [...]
> > Operating systems provide memory barriers as function calls. For POSIX you
> > can find a list of functions that issue the memory barrier here
> > 
> http://groups.google.com/groups?selm=opsf9kv0mjti5cme%40localhost.localdomain&rnum=2&filter=0.
> 
> In addition to the links I've posted in my previous message, see
> also <http://cmc.rice.edu/docs/docs/Adv1999Mar1RecentAdva.pdf>.
> 
> regards,
> alexander.
> 
> P.S. DRB it totally wrong with respect to {non}conformance of
> release consistency model, BTW.
> 
> --
> "The current POSIX memory model is far from perfect. [...] I 
>  really think you'd be far better off persuing this at the C++ 
>  language level and lobbying for a language threading model that 
>  can coexist with (carefully designed) POSIX implementations but 
>  is not directly dependent on the POSIX language."
> 
>    -- DRB (sorta annoyed by pseudo-C++ illustrations ;-) )

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply guy 11/8/2004 11:36:46 PM

guy.peleg@gmail.com (Guy) wrote in message
news:<f4d01807.0411072321.719f19e2@posting.google.com>...

 > Thanks but I think I need to rephrase the question.

 > Suppose I have a 'long'(in either 32-bit or 64-bit) I have a process
 > with two threads. One is reading this 'long' and one is writing it. Is
 > it possible that while the writing thread is in the middle of the
 > writing, the process will switched to the reading thread? Or is it
 > true to say that this action (updating or reading) this long is safe?

It's not possible to say anything.

I think your missing what most of the posters have been trying to tell
you.  Atomicity is not necessarily relevant.  You speak of switching
threads, for example.  But on many machines today, there are two or more
threads running simultaneously -- no thread switch is necessary for
problems to occur, and the issue is not just atomicity, but visibility.
On most machines, a thread switch can only occur on an instruction
boundary -- Intel processors have an increment memory instruction, and
if thread switching on a single processor were the only issue, that
would suffice for an atomic increment.  It doesn't, and it is not
without reason that processors have additional hardware synchronization
means; even 25 years ago, Intel required a LOCK prefix on an increment
in memory, if you wanted the operation to be atomic, and the plethory of
caches and pipelines in a modern processor just makes the issue more
complex.

Under Posix, the rule is simple: if any thread modifies, all accesses
must be serialized by means of one of the system locking mechanisms
(mutex, semaphore, etc.).  I suspect that the rule under Windows is the
same.  On the other hand, many systems provide additional, system
specific methods of serialization or synchronization, and in most cases,
if you're not afraid of a little assembler, you can avoid the system
synchronizations in specific cases.  (On both Sparc and Intel 32 bit
architectures, this involves special machine instructions that are never
generated by the compiler.)

If all you mean is that if you have a long with 0, and one thread writes
0xFFFFFFFF, then other threads can never see anything but 0 or
0xFFFFFFFF (and not, for example, 0xFFFF0000 or 0x0000FFFF), then the
answer still depends on the processor and the alignement of the data.
And theoretically, at least, it is possible that the other thread never
see the change unless you do something special.

--
James Kanze           GABI Software         http://www.gabi-soft.fr
Conseils en informatique orient�e objet/
                    Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply kanze 11/9/2004 12:22:19 PM

guy.peleg@gmail.com (Guy) wrote in message news:<f4d01807.0411072321.719f19e2@posting.google.com>...
 > Thanks but I think I need to rephrase the question.
 >
 > Suppose I have a 'long'(in either 32-bit or 64-bit) I have a process
 > with two threads. One is reading this 'long' and one is writing it. Is
 > it possible that while the writing thread is in the middle of the
 > writing, the process will switched to the reading thread? Or is it
 > true to say that this action (updating or reading) this long is safe?

There are no guarantees in C++, whether longs are 32, 33 or 64 bits.
Of course, there are no threads in C++, so this usually doesn't
matter. Once you use a threading extension to C++, that extension
should tell you - and you should ask your question in a group which
covers that extension.

Regards,
Michiel Salters

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply Michiel 11/9/2004 12:22:48 PM

Guy wrote:
 > Thanks but I think I need to rephrase the question.
 >
 > Suppose I have a 'long'(in either 32-bit or 64-bit) I have a process
 > with two threads. One is reading this 'long' and one is writing it. Is
 > it possible that while the writing thread is in the middle of the
 > writing, the process will switched to the reading thread? Or is it
 > true to say that this action (updating or reading) this long is safe?
<snip>

This is unanswerable without knowing the details of the running
environment (OS, processor architecture, library implementation...).
Multithreaded programs are outside the scope of the C++ standard.

-- 
Ben Hutchings
If God had intended Man to program,
we'd have been born with serial I/O ports.

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply Ben 11/9/2004 12:27:01 PM

guy.peleg@gmail.com (Guy) wrote
> Thanks but I think I need to rephrase the question. 
> 
> Suppose I have a 'long'(in either 32-bit or 64-bit) I have a process
> with two threads. One is reading this 'long' and one is writing it. Is
> it possible that while the writing thread is in the middle of the
> writing, the process will switched to the reading thread? Or is it
> true to say that this action (updating or reading) this long is safe?

I don't think you've asked anything here that wasn't assumed the first
time around. In any case, the answer doesn't change: it's still NO.

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply allan_w 11/9/2004 9:11:44 PM
comp.lang.c++.moderated 10642 articles. 9 followers. Post

12 Replies
191 Views

Similar Articles

[PageSpeed] 27


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Atomic variable Vs. Atomic operation
Hi, Lets say I have two shared variables a,b which are related to each other. When multiple applications share these shared variables, access to them needs to be an atomic operation, otherwise the relation may break. So to ensure mutual exclusion, I'll put their modification under a critical section protected by lock. critical_code { P(mutex) a := something b := something V(mutex) } Lets say my hardware/OS/compiler supports atomic variables. Then I modified my above code as follows. code { atomic a := something atomic b := something } Can this code ensure mutua...

Atomic variable Vs. Atomic operation
Hi, Lets say I have two shared variables a,b which are related to each other. When multiple applications share these shared variables, access to them needs to be an atomic operation, otherwise the relation may break. So to ensure mutual exclusion, I'll put their modification under a critical section protected by lock. critical_code { P(mutex) a := something b := something V(mutex) } Lets say my hardware/OS/compiler supports atomic variables. Then I modified my above code as follows. code { atomic a := something atomic b := something } ...

Atomic variable Vs. Atomic operation
Hi, Lets say I have two shared variables a,b which are related to each other. When multiple applications share these shared variables, access to them needs to be an atomic operation, otherwise the relation may break. So to ensure mutual exclusion, I'll put their modification under a critical section protected by lock. critical_code { P(mutex) a := something b := something V(mutex) } Lets say my hardware/OS/compiler supports atomic variables. Then I modified my above code as follows. code { atomic a := something atomic b := something } C...

Pseudo-atomic
http://semipublic.comp-arch.net/wiki/Pseudo-atomic [[Pseudo-atomic]] is a term that I (Glew) have coined to refer to atomic operations that can fail to be atomic, such as: * [[Load-linked/store-conditional (LL/SC)]] * IBM z196's [[LOAD PAIR DISJOINT]] * even [[hardware transactional memory]] ** such as [[Intel Transactional Synchronization Extensions (TSX)]]'s [[Restricted Transactional Memory (RTM)]], where "the [[XBEGIN]] instruction takes an operand that provides a relative offset to the fallback instruction address if the RTM region could not be successfully executed tra...

Atomic operations!!
Hi all I am porting an application from AIX to solaris, I just wanted to whether any equivalent APIs available on Solaris for these AIX routines such as, compare_and_swap(),_check_lock(),fetch_and_and () Thanks in advance, Seema Rao "seema" <seema_coma@yahoo.co.in> writes: >Hi all I am porting an application from AIX to solaris, I just wanted >to whether any equivalent APIs available on Solaris for these AIX >routines such as, > compare_and_swap(),_check_lock(),fetch_and_and () While compare_and_swap() is an obvious function, it would be nice if you told ...

Is this operation atomic?
I'm finishing up a total rewrite of an interrupt-heavy program (the previous version was a nightmare of pushf/cli/popf wrapping to prevent race conditions in code shared by multiple interrupt handlers -- don't ask) and I have been staring at it for so long that I am confusing myself as to which operations can be considered atomic or not. Here is clearing a flag variable (this is 16-bit real mode x86): C6060A0000 MOV BYTE PTR [000A],0 Can I consider this operation atomic, or can this somehow be interrupted once instruction decoding and execution has begun? Jim Leonard wro...

Atomic operations
Hi folks, what's the easiest way to call atomic operations like fetch-and-add and compare-and-swap with gcc on x86-64 Linux? Any (builtin) calls or intrinsics. I found some inline assembler macros, but they don't seem to work on 64-bit pointers: # define FETCH_AND_ADD(address,increment) \ asm volatile ( \ "lock xaddl %0,%1" \ : "=r" (increment), "=m" (address) \ : "0" (increment) : "memory"); There also is __gnu_cxx::__exchange_and_add(counter0_ptr, increment); but I'm not sure whether I'm "allowed" to cal...

Atomic Operation
I read sometime ago that there is new java feature to increment a long as atomic operation so threads can safely add one to the long. I cannot find name for such object, I think "AtomicLongIncrement" or something. Maybe someone can remember. I have been searching java doc, but cannot find it. dimitrik107@hotmail.com wrote: > I read sometime ago that there is new java feature to increment a long > as atomic operation so threads can safely add one to the long. I cannot > find name for such object, I think "AtomicLongIncrement" or something. > Maybe someone can ...

Functions for atomic operation.
Dear All, Is there any functions available in standard C library or in the library that comes with gcc, which can do atomic increaments and atomic decrements? (other atomic operations optional... though highly preferable...) for example, functions like this: atomic_inc(); atomic_dec(); so that for such small operations user need not write its own functions using semaphore or mutex. This could be handy while programming for parallel processes or threads. Thanks Srinu On 30 Sep, 06:10, Srinu <sinu.nayak2...@gmail.com> wrote: > Is there any functions available in standard C librar...

atomic operations in Linux?
Hi all, I am developing in C with the pthread library under Linux. For performance reasons, I am in need of atomic inc/decrement and either an atomic swap function or an atomic set and atomic read. All of that could work on integer values. Unfortunately, pthread does does offer any atomic operations itself. Is there any way to use them in a fairly portable way? Suggestions would be deeply appreciated. Thanks, Rainer PS: I am working on the rsyslog project (http://www.rsyslog.com) if that matters to someone. On Jan 15, 4:56 pm, rgerhards <rgerha...@gmail.com> wrote: > Hi all, >...

is ternary operator atomic?
Hello All, I have a question regarding the ternary operator usage in C and C++. If I write, ----------------- a = (a==9) ? 10 : 0; // a is an integer defined already ---------------------------------------- Is the ternary operator statement atomic across all platforms. By atomic, i mean can it be guaranteed that while this statement is being executed, context will not be switched between multiple threads in the same process space. Is there any such mention in the C/C++ standard, Or it is compiler dependent. Thanks, Saurabh Gupta On 01/07/2010 07:48, s...

atomic operation problem
Hi, I want to do protect some of the critical regions in my program.But I can not use something like semaphore.Because I do not need any wait queues.If any task failed to access critical region, it can just return an error. When I read the source code of the Linux, I found some of the functions use 'lock' field in the assembly language. I can not fully understand how to use this 'lock' field. Could any one give me some tips, or a link address which I can found more details about the protection of cirtical region. "leilei" <huxuelei630@gmail.com> wrote in messa...

LeaveCriticalSection Atomic operation
Hi all, I had a problem with my critical section because I called LeaveCriticalSection without EnterCriticalSection. Why calling leave without calling enter creats a problem? I figured that in order to make Leave and Enter atomic operations you can only inc\dec the lock count without any IFs and other operations... my question is... what is the need of making LeaveCriticalSection an Atomic operation? In article <efcbcb2b-3146-4c5d-86af-418915d31e78@y5g2000hsf.googlegroups.com>, ManicQin@gmail.com (ManicQin) wrote: I presume you've using Windows, given the names of the function...

Multithreading and atomic operations
I am a bit confused on the subject. In multithreading, isn't an atomic operation a piece of code that must be run by only one thread at a time? Thanks. "Ioannis Vranos" <ivranos@no.spam.freemail.gr> wrote in message news:gmjs11$1q4l$1@ulysses.noc.ntua.gr... >I am a bit confused on the subject. > > In multithreading, isn't an atomic operation a piece of code that must be > run by only one thread at a time? It means that a series of operations appear to happen all at once, or none at all (e.g., conditional atomic ops). An atomic operation which mutate...

arguments to atomic operations
Hi, I am not too familiar with atomic operations in C++0x. I would like to ask a couple of questions. But perhaps the example will illustrate all of them already. std::memory_order mo = x.load( std::memory_order_acquire ); int i = y.load( mo ); What can be said about this example: 1. That while this an untypical one, it might be useful for some clever or hakish solutions? 2. It will never work because the parameter for loads stores must be known at compile time? Every example I have seen always provides literals in the parameter, and I came to believe that the syntax sh...

atomic operations on Win32
From MSDN 'Simple reads and writes to properly-aligned 32-bit variables are atomic', I understand the principle but I'm not clear what exactly it means in terms of C++ code. What can I (and can't I) do in C++ and expect it to be an atomic operation. Some example code would be great. Thanks John John Harrison wrote: > From MSDN 'Simple reads and writes to properly-aligned 32-bit variables are > atomic', I understand the principle but I'm not clear what exactly it means > in terms of C++ code. What can I (and can't I) do in C++ and ex...

Multicore and atomic operations
Hi All, In order to utilize the mutiple core inside a single chip, I am planning to implement a library of basic data types which will support atomic operations. I believe that due to this it will minimize the waiting time which generally occures due to mutiple threads asking for same resource. I need your comments for 1) Can atomic operations really to help me to use mutiple core in efficient way? 2) How in general people do this? (any pointers?) 3) I am not sure about concurrent containers and algorithms. Do I need to develope them as well? automic opersions will not be sufficient? 4) D...

Atomic operation and volatile variables
Hi , I have one volatile variable declared as private volatile long _volatileKey=0; This variable is being incremented(++_volatileKey) by a method which is not synchronized. Could there be a problem if more than one thread tries to change the variable ? In short is ++ operation atomic in case of volatile variables ? Thanks Sumukh "Sumukh" <sumukh@DontSpam.org> wrote in message news:1127479330.108250@sj-nntpcache-3... > Hi , > I have one volatile variable declared as > > private volatile long _volatileKey=0; > > This variable is being incremented(++_vol...

atomic memory-operation question
Does anyone know which current architecutres are able to do an atomic compare-&-conditional-exchange where the operand-size is at least twice the size of a pointer ? x86's have the cmpxchg8b which is very nice for lock-free data-structures (like pools). "Oliver S." <Follow.Me@gmx.net> writes: > Does anyone know which current architecutres are able to do an atomic > compare-&-conditional-exchange where the operand-size is at least twice > the size of a pointer ? x86's have the cmpxchg8b which is very nice for > lock-free data-structures (like pools...

atomic operations in presence of multithreading
I am wondering which operations in Python are guaranteed to be atomic in the presence of multi-threading. In particular, are assignment and reading of a dictionary entry atomic? For example, initially: dictionary = {} dictionary[key] = old_value Then thread 1 does: v = dictionary[key] And thread 2 does: dictionary[key] = new_value2 And thread 3 does: dictionary[key] = new_value3 What I want to make sure of is that thread 1 will read either the old_value for key, or new_value2, or new_value3, but not an intermediate value. Which value in particular does not matter to me, as that...

Atomic/transaction operations on UFS
Hello, I'm trying to update a file on a remote file system and what to do this in as safe a way as possible. ssh/scp must be used, so I am copying the file to a temporary file on the same filesystem on the remote host. The problem is when it comes to replacing the old with the new. The only two ways I can think of replacing the old file with the new would are: 1. A straight copy over the top 2. Unlink the old version and mv the new version to the same file name. The file doesn't need to keep the same inode. The risk I can see is that something happens during the replacement leavin...

Are appends to a file an atomic operation?
I had a log file to which multiple processes append single line status- messages at intervals. echo "foo long line" >> logfile I guess the writing of a line takes a finite time. Is there a chance of a corrupted line if another process tries to write its line to the log at the same time? echo "bar long line" >> logfile If so then I'd have to impliment some kind of lock. Also, what about operations that read from the log. Is there ever a chance that they get a partial log line if it is in the process of being written? Does it matter i...

Memory barriers in atomic operations
According to the Apple's documentation there exist pairs of functions to perform atomic operations such as OSAtomicIncrement32()/OSAtmoicIncrement32Barrier(). http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/OSAtomicIncrement32Barrier.3.html "Barriers strictly order memory access on a weakly-ordered architecture such as PPC. All loads and stores executed in sequential program order before the barrier will complete before any load or store executed after the barrier." However, it is not clear whether the memory barrier must be used: ...

External access
Hi, assuming an 8-Bit peripheral device is connected to the external bus interface of an AT91R40008 (EBI is also setup for a 8-Bit device; EBI_DBW_8) and a word/32-Bit or half-word/16-Bit access is performed to this device.. Does anybody know if this is an atomic operation? Could the sequence of n byte accesses be interrupted by an IRQ/FIQ? Ralf ...