lkml.org 
[lkml]   [2006]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [patch] spinlocks: remove 'volatile'
    Date
    On Sat, 8 Jul 2006, Chase Venters wrote:
    >
    >Perhaps you should have followed this thread closely before composing your
    >assault on Linus. We're not talking about "asm volatile". We're talking
    >about
    >the "volatile" keyword as applied to variables. 'volatile' as applied to
    >inline ASM is of course necessary in many cases -- no one is disputing
    >that.
    >

    Ok, let's port a spinlock macro that spins instead of context switches
    instead of using the pthread garbage on IA64 or AMD64:

    #if ((defined (_M_IA64) || defined (_M_AMD64)) && !defined(NT_INTEREX))
    #include <windows.h>
    #pragma intrinsic (_InterlockedExchange)

    typedef volatile LONG lock_t[1];

    #define LockInit(v) ((v)[0] = 0)
    #define LockFree(v) ((v)[0] = 0)
    #define Unlock(v) ((v)[0] = 0)

    __forceinline void Lock(volatile LONG *hPtr)
    {
    int iValue;

    for (;;) {
    iValue = _InterlockedExchange((LPLONG)hPtr, 1);
    if (iValue == 0)
    return;
    while (*hPtr);
    }
    }

    Please show me how I can write this to spinlock without using volatile.

    Trajce Nedev
    tnedev@mail.ru

    _________________________________________________________________
    Express yourself instantly with MSN Messenger! Download today - it's FREE!
    http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

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

    \
     
     \ /
      Last update: 2006-07-08 08:47    [W:0.049 / U:94.380 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site