Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Jeff Denham <jdenham@brighttiger.com>
Subject: Re: mutex between processes?
Date: 1998/08/07	[thread overview]
Message-ID: <35CB2911.61856927@brighttiger.com> (raw)
In-Reply-To: 35CAC907.497400F4@orga.com

Aurel Balmosan wrote:

> Dirk Grunwald wrote:
>
> > But, in a 'mmap' region, you can also use the native spinlock/critical
> > section mechanisms. These will differ from machine to machine.
> >
>
> Does it work also on shared memory (I would guess so)And what about DEC-Alpha
> with lets say 12 processors?
>
> >          /* might not be needed, ya never know and
> >             you're not doing much else right now anyway.. */
> >           __MB();
> >
>
> What is that? What does a Memory Barrier do and why is it needed?

Yes, the spinlock approach will work in any support form
of shared memory.

Whether a spinlock is appropriate for your app depends on
the size/duration of your critical sections. If you'll have
lots of contention of the lock or the lock is held for
"long" periods, then the system call is a win. There's
a crossover point where spinning no longer pays
off.

The __MB() (memory barrier)  is *absolutely* necessary for the spinlock to work
on an MP system. In Dirk's example, though,
I'm pretty sure that the __MB() in the release() routine
is in the wrong place -- it should be before the clearing
of the lock, not after. This guarantees that the
updates to the object being locked are seen by other
processors before they see that the lock is clear, grab it,
and see stale state in the object.

The more aggressive your memory subsystem is
at optimizing (i.e., reodering) its traffic to main
memory (can you say 21264?), the more quickly
your missing or misplaced memory barriers
will screw you.

Jeff
__________________________________________________
Jeff Denham (jdenham@brighttiger.com)

Bright Tiger Technologies
SmartCluster� Software for Distributed Web Servers
http://www.brighttiger.com

125 Nagog Park
Acton, MA 01720
Phone: (978) 263-5455 x177
Fax:   (978) 263-5547





  reply	other threads:[~1998-08-07  4:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-04  4:00 mutex between processes? Aurel Balmosan
1998-08-05  4:00 ` Jeff Denham
1998-08-05  4:00   ` Dirk Grunwald
1998-08-07  4:00     ` Aurel Balmosan
1998-08-07  4:00       ` Jeff Denham [this message]
1998-08-07  4:00         ` Aurel Balmosan
1998-08-07  4:00           ` Monty Brandenberg
1998-08-09  4:00             ` Aurel Balmosan
1998-08-10  4:00         ` Dirk Grunwald
1998-08-10  4:00           ` Monty Brandenberg
1998-08-10  4:00             ` Dirk Grunwald
1998-08-10  4:00               ` Monty Brandenberg
1998-08-11  4:00                 ` Aurel Balmosan
1998-08-11  4:00                   ` Monty Brandenberg
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox