From owner-freebsd-ia64 Wed Oct 10 10:17:48 2001 Delivered-To: freebsd-ia64@freebsd.org Received: from mail12.speakeasy.net (mail12.speakeasy.net [216.254.0.212]) by hub.freebsd.org (Postfix) with ESMTP id 2E4BC37B40C for ; Wed, 10 Oct 2001 10:17:45 -0700 (PDT) Received: (qmail 91178 invoked from network); 10 Oct 2001 17:17:44 -0000 Received: from unknown (HELO laptop.baldwin.cx) ([64.81.54.73]) (envelope-sender ) by mail12.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 10 Oct 2001 17:17:44 -0000 Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20011010100824.Y549-100000@salmon.nlsystems.com> Date: Wed, 10 Oct 2001 10:17:10 -0700 (PDT) From: John Baldwin To: Doug Rabson , jdp@FreeBSD.org Subject: RE: rtld -- atomic ops Cc: ia64@freebsd.org Sender: owner-freebsd-ia64@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On 10-Oct-01 Doug Rabson wrote: > +/* > + * Thread locking implementation for the dynamic linker. > + * > + * We use the "simple, non-scalable reader-preference lock" from: > + * > + * J. M. Mellor-Crummey and M. L. Scott. "Scalable Reader-Writer > + * Synchronization for Shared-Memory Multiprocessors." 3rd ACM Symp. on > + * Principles and Practice of Parallel Programming, April 1991. > + * > + * In this algorithm the lock is a single word. Its low-order bit is > + * set when a writer holds the lock. The remaining high-order bits > + * contain a count of readers desiring the lock. The algorithm requires > + * atomic "compare_and_store" and "add" operations, which we implement > + * using assembly language sequences in "rtld_start.S". > + * > + * These are spinlocks. When spinning we call nanosleep() for 1 > + * microsecond each time around the loop. This will most likely yield > + * the CPU to other threads (including, we hope, the lockholder) allowing > + * them to make some progress. > + */ One quick question. Now that we have a MI atomic operation interface one can get from that includes atomic_cmpset_acq_int(), atomic_add_acq_int(), and atomic_add_rel_int(), why not use these instead of re-rolling the atomic operations each time? I realize that do to the quirky nature of the 386, you would still have to have a hack for the x86 platform, but at least for 486+ and other arch's you could just use the pre-existent API so that we only have to code up atomic ops in one place. Comments? -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ia64" in the body of the message