Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 May 2013 06:51:01 +0000
From:      Orit Moskovich <oritm@mellanox.com>
To:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   FreeBSD spinlock
Message-ID:  <981733489AB3BD4DB24B48340F53E0A55B0CDE16@MTLDAG01.mtl.com>

Next in thread | Raw E-Mail | Index | Archive | Help
Hi,

I read a bit about the FreeBSD mutex implementation for spinlock.
I might be wrong, but I noticed a code section that might be problematic:

Taken from http://svn.freebsd.org/base/release/9.1.0/sys/ofed/include/linux=
/spinlock.h:

static inline void
spin_lock_init(spinlock_t *lock)
{

        memset(&lock->m, 0, sizeof(lock->m));
        mtx_init(&lock->m, "lnxspin", NULL, MTX_DEF | MTX_NOWITNESS);
}

But MTX_DEF initializes mutex as a sleep mutex:

By default, MTX_DEF mutexes will context switch when they are already

     held.


There is a flag MTX_SPIN Which I think is the right one in this case .



I'd appreciate your take on this issue.



Thanks,

Orit Moskovich




Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?981733489AB3BD4DB24B48340F53E0A55B0CDE16>