Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Oct 2002 14:05:08 +0300
From:      Peter Pentchev <roam@ringlet.net>
To:        Andrei Cojocaru <spinlock_lists@empirequest.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Question about light-weight mutex (kind of)
Message-ID:  <20021011110508.GR376@straylight.oblivion.bg>
In-Reply-To: <000d01c270c8$937a2160$0200a8c0@twothousand>
References:  <000d01c270c8$937a2160$0200a8c0@twothousand>

next in thread | previous in thread | raw e-mail | index | archive | help

--kb0TSCuX821Ar6UT
Content-Type: text/plain; charset=windows-1251
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Oct 10, 2002 at 07:50:28PM -0600, Andrei Cojocaru wrote:
> Hello,
>=20
> I have a question, please include me in the reply specifically because I'm
> not subscribed to the mailing list. Thanks
>=20
> I want a thread to spin atomically on a value until it's equal to 1(i.e.
> it's waiting for an event), how do I do that? I have no idea.. I want this
> to be fast, not have to use a mutex each time to protect the value
> I have an idea of how to do it using atomic assembly statements but I don=
't
> want to use assmebly, I want to know if FreeBSD has built-in stuff for th=
is.
>=20
> Please help thanks.
>=20
> This is required because I'm building R/W locks for a transaction system =
I'm
> working on, and I need a way for a thread waiting on a lock to be notified
> when a lock is gotten (and without having the thread block [that's why I
> want it to spin]). Any hints would be appreciated thanks, once again.

Would pthread_rwlock_tryrdlock(3) and pthread_rwlock_tryrdlock(3),
combined with an usleep() or something, do the trick?

G'luck,
Peter

--=20
Peter Pentchev	roam@ringlet.net	roam@FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
Hey, out there - is it *you* reading me, or is it someone else?

--kb0TSCuX821Ar6UT
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (FreeBSD)

iD8DBQE9prBj7Ri2jRYZRVMRAmt+AKC/oJo9741nSXyOH2sYqH14Qs/6igCgmjWA
sksrumvN/IPLw0zhDKJ4s+o=
=g1Ol
-----END PGP SIGNATURE-----

--kb0TSCuX821Ar6UT--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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