lkml.org 
[lkml]   [2000]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] Wine speedup through kernel module
On Thu, Sep 07, 2000 at 04:25:29PM +0100, David Howells wrote:
>
> Andi Kleen <ak@suse.de> wrote:
> > But that's not race free on SMP. Two CPUs can set the bit in parallel
> > and you'll never notice. You would need at least a protecting spinlock
> > between the test bit and set bit (or a cmpxchg on x86)
>
> Are you sure? I understood that the "lock" prefix on a i386 made the
> instruction it guarded SMP safe.
>
> If not, I suppose I can use the xchg() macro instead.
>
> Hold on a moment... You said "between the test bit and set bit"... this is a
> single CPU instruction! With the lock prefix, there should be no between.

This is far from a single CPU instruction between the test_bit and the
set_bit. Even with a single CPU instruction you would need a cmpxchg with
retry BTW, to handle the case of multiple CPUs entering the instruction at
the same time. The easiest fix is to add a spinlock per mutex.

if (test_bit(0,&mutex->wm_state) || mutex->wm_owner!=filp) {
ret = 0; /* false */
} else {
ret = 1;
mutex->wm_owner = NULL;
set_bit(0,&mutex->wm_state);
SignalObject(obj,1);
}




-Andi

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.077 / U:1.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site