From owner-freebsd-hackers Fri Oct 11 4: 6:50 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 28F1837B401 for ; Fri, 11 Oct 2002 04:06:48 -0700 (PDT) Received: from south.nanolink.com (south.nanolink.com [217.75.134.10]) by mx1.FreeBSD.org (Postfix) with SMTP id EC5E943E97 for ; Fri, 11 Oct 2002 04:06:46 -0700 (PDT) (envelope-from roam@ringlet.net) Received: (qmail 85204 invoked by uid 85); 11 Oct 2002 11:17:38 -0000 Received: from office.sbnd.net (HELO straylight.ringlet.net) (217.75.140.130) by south.nanolink.com with SMTP; 11 Oct 2002 11:17:36 -0000 Received: (qmail 5599 invoked by uid 1000); 11 Oct 2002 11:06:40 -0000 Date: Fri, 11 Oct 2002 14:06:40 +0300 From: Peter Pentchev To: Andrei Cojocaru Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Question about light-weight mutex (kind of) Message-ID: <20021011110640.GS376@straylight.oblivion.bg> Mail-Followup-To: Andrei Cojocaru , freebsd-hackers@FreeBSD.ORG References: <000d01c270c8$937a2160$0200a8c0@twothousand> <20021011110508.GR376@straylight.oblivion.bg> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gJgGjUUWrnN4mpen" Content-Disposition: inline In-Reply-To: <20021011110508.GR376@straylight.oblivion.bg> User-Agent: Mutt/1.5.1i X-Virus-Scanned: by Nik's Monitoring Daemon (AMaViS perl-11d ) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --gJgGjUUWrnN4mpen Content-Type: text/plain; charset=windows-1251 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 11, 2002 at 02:05:08PM +0300, Peter Pentchev wrote: > 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 t= his > > 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 d= on't > > want to use assmebly, I want to know if FreeBSD has built-in stuff for = this. > >=20 > > Please help thanks. > >=20 > > This is required because I'm building R/W locks for a transaction syste= m I'm > > working on, and I need a way for a thread waiting on a lock to be notif= ied > > 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. >=20 > Would pthread_rwlock_tryrdlock(3) and pthread_rwlock_tryrdlock(3), > combined with an usleep() or something, do the trick? Of course, the second one was meant to be pthread_rwlock_trywrlock(3)... 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? --gJgGjUUWrnN4mpen Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (FreeBSD) iD8DBQE9prDA7Ri2jRYZRVMRAhuQAJ9K48926OOnfaLkdk+Bk/1AMh8XCgCfaBW1 GbOjBY+grYyUxL9PfF4xgIU= =xkYo -----END PGP SIGNATURE----- --gJgGjUUWrnN4mpen-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message