Re: multi thread app and often variable accessing

2007-06-11 Thread wallace . owen
On Fri, 2007-06-08 at 19:41 -0600, Jim George wrote: > > Begin Curiosity: > > > Also, the hardware must have something like the Pentium CMPXCHG8B [...] > > Is it not > > sufficient to be able to write an int in one single bus access? ie > > have a 32-bit wide data bus > > Or is that exactly the poi

Re: multi thread app and often variable accessing

2007-06-08 Thread Jim George
> Begin Curiosity: > > Also, the hardware must have something like the Pentium CMPXCHG8B [...] > Is it not > sufficient to be able to write an int in one single bus access? ie > have a 32-bit wide data bus > Or is that exactly the point? :D > No, in most cases, if you want to atomically increment o

Re: multi thread app and often variable accessing

2007-06-08 Thread Yeti
On Fri, Jun 08, 2007 at 09:27:38PM +0200, David Nečas (Yeti) wrote: > > Attempts to use atomic operations without considering memory [*] > access ordering guarantee subtle bugs... [*] as a substitute for locking. Yeti -- http://gwyddion.net/ __

Re: multi thread app and often variable accessing

2007-06-08 Thread Yeti
On Fri, Jun 08, 2007 at 08:51:08PM +0200, Jonathan Winterflood wrote: > > > If you don't know what memory ordering, barriers, etc. [...] > Indeed I don't know what these are either. Any chance that someone does? See Documentation/memory-barriers.txt in Linux source code, on-line available for

Re: multi thread app and often variable accessing

2007-06-08 Thread Jonathan Winterflood
On 6/8/07, Tomasz Jankowski <[EMAIL PROTECTED]> wrote: > > In fact I write library, but it's based on GLIb, so my library will be > available only on platforms where GLib is available - problem resolved > itself ;P Returning to main problem, maybe for sure, I will add another > mutex used only for

Re: multi thread app and often variable accessing

2007-06-08 Thread Jim George
> On 6/8/07, Tomasz Jankowski <[EMAIL PROTECTED] > wrote: > > > > Hi! > > > > I'm working on small multi thread application based on Gobject. In one of > > my > > objects I have integer variable, which determine current object's status. > > The problem is, that I need to read it's status really oft

Re: multi thread app and often variable accessing

2007-06-08 Thread Jonathan Winterflood
Hi, As far as I understand, g_atomic_int_get/set will do the job just fine, as long as you're sure the only part that needs to be atomic is the getting and setting. However, if the hardware you are running on does not provide an atomic way of getting/setting an int, (eg: int is an int32 and the ha

multi thread app and often variable accessing

2007-06-07 Thread Tomasz Jankowski
Hi! I'm working on small multi thread application based on Gobject. In one of my objects I have integer variable, which determine current object's status. The problem is, that I need to read it's status really often, so it will be to expensive to lock and unlock mutex all the time. Can I use there