Discussion:
Shared/exclusive (rw) locks
(too old to reply)
n***@ur.ru
2004-07-06 04:31:27 UTC
Permalink
Hello

What locks are in freebsd stable kernel ?
I have found only simplelock, what else ?

Thanks,

Nik
t***@freebsd.org
2004-07-06 04:57:14 UTC
Permalink
Post by n***@ur.ru
Hello
What locks are in freebsd stable kernel ?
I have found only simplelock, what else ?
lockmgr() -- see /sys/kern/kern_lock.c.


Tim
t***@freebsd.org
2004-07-06 05:37:51 UTC
Permalink
Post by n***@ur.ru
Thanks
I've found it too.
But
/*
* The general lock structure. Provides for multiple shared locks,
* upgrading from shared to exclusive, and sleeping until the lock
* can be gained. The simple locks are defined in <machine/param.h>.
*/
What means sleeping ? I need spinlock.
I cannot allow to fall asleep to kernel thread.
You'll need to use simplelocks or spls then, as appropriate to the
situation.


Tim

P.S.: This probably isn't the right mailing list for this discussion.
t***@freebsd.org
2004-07-06 07:14:18 UTC
Permalink
That means, freebsd stable has no spin rwlocks ?
Right. Reader-writer spinlocks would not be very useful in FreeBSD 4; because
only one thread can be running in the kernel at once, the only opportunity
you'd have to share reader locks would be if you slept while holding a
spinlock, which is a bad idea (and not permitted by FreeBSD 5 or Linux).
If you want -rwlocks, you'll have to use lockmgr() (which is a sleep lock).


Tim

Loading...