Re: [gtk-list] Re: callback synchronisation



I've just noticed I never answered the paragraph quoted below. It might be
of general interest, so...

Paul Barton-Davis wrote:

> >> I need to do this as well sometimes, so I use <asm/atomic.h> on Linux
> >> and equivalents on other systems. Within critical sections, I do this:
> >
> >Not available on Solaris in userland. :-(
> 
> actually, they are, but they are not wrapped nicely. all architectures
> have atomic data types for increment and decrements. all sane
> architectures anyway, and the SPARC/x86 that Solaris runs on are among
> the reasonably sane.

It's not that simple on SPARCs (I don't know about x86). SPARC has the
instructions, but they are not enough. Suppose we have two threads running
each on one processor and we're interested in modifying some piece of shared
data which resides in cache on both processors. One thread will modify the
data and it will be written to the main memory immediately, but it won't go
into other processor's cache (even if written with read-modify-write
instruction). That's why one has to use thread locking/unlocking functions
around such pieces of code. Those functions will execute kernel code and the
kernel will synchronize processor caches. Functions which do that are
not available in userland (except as being part of thread locking sequence).

A nice example of applications which probably don't do proper locking are
IE5 and Outlook. They are multithreaded, but if you run them on a
multiprocessor, they will crash every few minutes or so. Microsoft claims
that this is because of limitation in Solaris 2.6, but I kind of don't
trust them. :-)

-- 
 .-.   .-.    I don't work for my employer.
(_  \ /  _)
     |        dave@srce.hr
     |        dave@fly.srk.fer.hr



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]