On Tue, 2 Jan 2007, Ming Zhang wrote: > Hi All > > In this document coming with kernel source, it has > > " int atomic_inc_and_test(atomic_t *v); > int atomic_dec_and_test(atomic_t *v); > > These two routines increment and decrement by 1, respectively, the > given atomic counter. They return a boolean indicating whether the > resulting counter value was zero or not. > > It requires explicit memory barrier semantics around the operation > as above." > > Do this mean the code who call such functions should take care about > the barrier? or such functions take care for us already? as i read it, it means that the memory barriers must be supplied by *someone* -- in this case, they should be part of the functions so you don't have to supply them yourself. an easy way to see this is to search the kernel source tree and see examples of that routine, to see how often memory barriers are added: $ grep -r -A5 -B5 atomic_inc_and_test * | less as you can see, there don't appear to be explicit memory barriers, so you shouldn't have to add them. rday -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/