Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Jan 2012 07:54:02 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        dmitry.krivenok@emc.com
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: mtx_trylock() on a spin mutex
Message-ID:  <201201310754.02343.jhb@freebsd.org>
In-Reply-To: <9C7BACB01B839A499792154E76C9ADE5563FDD39ED@MX19A.corp.emc.com>
References:  <9C7BACB01B839A499792154E76C9ADE5563FDD39ED@MX19A.corp.emc.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, January 31, 2012 6:35:08 am dmitry.krivenok@emc.com wrote:
> Hello,
> Could someone please explain why mtx_trylock() must not be called on a spin mutex?
> Is it conceptually wrong or is it a restriction of FreeBSD kernel implementation?

The current mutex API generally uses different methods for the different types of
mutexes (at some point I may split spin locks out into a completely separate
API to simplify things).  If we wanted to do trylocks on spinlocks, then a new
mtx_trylock_spin() method would be added as you've done.  To date we haven't had
any use cases for trylock operations on a spin lock.  Even try locks on other
locking primitives are used fairly rarely.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201310754.02343.jhb>