Date: Wed, 10 Oct 2001 10:17:10 -0700 (PDT) From: John Baldwin <jhb@FreeBSD.org> To: Doug Rabson <dfr@nlsystems.com>, jdp@FreeBSD.org Cc: ia64@freebsd.org Subject: RE: rtld -- atomic ops Message-ID: <XFMail.011010101710.jhb@FreeBSD.org> In-Reply-To: <20011010100824.Y549-100000@salmon.nlsystems.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <machine/atomic.h> 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 <jhb@FreeBSD.org> -- 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.011010101710.jhb>