kernel/lockmgr: Add lockmgr_try().
authorSascha Wildner <saw@online.de>
Sat, 21 Jul 2018 08:28:17 +0000 (10:28 +0200)
committerSascha Wildner <saw@online.de>
Sat, 21 Jul 2018 08:31:00 +0000 (10:31 +0200)
commita9ea406521403b6b39c4d2c3813488a5d29f77fe
tree080f3b733c734a5c8ca588271a0b62ccb9e5461a
parentc6bb9a9028d40ac817af6383d35164370e6480be
kernel/lockmgr: Add lockmgr_try().

It just adds LK_NOWAIT to the flags and returns whether the
lock was obtained.

It is similar to other functions such as spin_trylock() or
FreeBSD's mtx_trylock() and can be used to port the latter.

Note that like these functions, it returns TRUE if successful,
while lockmgr() returns 0 if successful. This difference was
the source of minor confusion and porting mistakes in the past.
In fact, our driver porting document also didn't point out this
difference. I will fix some of these little issues in a separate
commit.
doc/porting_drivers.txt
share/man/man9/Makefile
share/man/man9/lock.9
sys/sys/lock.h