From: David Edelsohn <dje@watson.ibm.com>
To: Joel Klecker <jk@espy.org>
Cc: dhd@debian.org, linuxppc-dev@lists.linuxppc.org, libc-alpha@cygnus.com
Subject: Re: DB_THREAD support in Berkeley DB/glibc
Date: Tue, 28 Dec 1999 14:02:03 -0500 [thread overview]
Message-ID: <199912281902.OAA25964@mal-ach.watson.ibm.com> (raw)
In-Reply-To: Message from Joel Klecker <jk@espy.org> of "Tue, 28 Dec 1999 09:53:58 PST." <v04220802b48ea8ff2961@[206.163.71.146]>
+/*
+ * PowerPC spinlock, adapted from the Alpha and m68k ones by dhd@debian.org
+ *
+ * For gcc/powerpc, 0 is clear, 1 is set (but *tsl will always be 0 since it's a char)
+ */
+#define TSL_SET(tsl) ({ \
+ register tsl_t *__l = (tsl); \
+ register tsl_t __r1; \
+ __asm__ volatile(" \n\
+ 10: lwarx %0,0,%1 \n\
+ cmpwi %0,0 \n\
+ bne+ 20f \n\
+ stwcx. %2,0,%1 \n\
+ bne- 10b \n\
+ 20: " \
+ : "=&r" (__r1) \
+ : "r" (__l), "r" (-1) : "cr0", "memory"); \
+ !__r1; \
+})
+
+#define TSL_UNSET(tsl) (*(tsl) = 0)
+#define TSL_INIT(tsl) TSL_UNSET(tsl)
The TSL_SET macro is basically correct for PowerPC uniprocessor,
but it is not MP safe. For cases where this needs to be safe across a
multiprocessor complex, it should be preceded by a "sync" instruction and
ended with an "isync" instruction, or something similar depending on the
semantics one uses for accessing the word.
It is not clear to me why the TSL_UNSET macro is sufficient.
David
===============================================================================
David Edelsohn T.J. Watson Research Center
dje@watson.ibm.com P.O. Box 218
+1 914 945 4364 (TL 862) Yorktown Heights, NY 10598
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
next prev parent reply other threads:[~1999-12-28 19:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-12-27 3:04 DB_THREAD support in Berkeley DB/glibc Troy Benjegerdes
1999-12-28 7:59 ` Daniel Jacobowitz
1999-12-28 17:53 ` Joel Klecker
1999-12-28 19:02 ` David Edelsohn [this message]
1999-12-28 21:22 ` BenH
1999-12-28 22:05 ` Daniel Jacobowitz
1999-12-28 22:28 ` David Edelsohn
1999-12-28 23:21 ` Tony Mantler
1999-12-29 0:15 ` David Edelsohn
1999-12-29 0:54 ` Geoff Keating
1999-12-29 1:01 ` David Edelsohn
1999-12-28 23:52 ` Geoff Keating
1999-12-29 0:21 ` David Edelsohn
-- strict thread matches above, loose matches on Subject: below --
1999-05-10 23:59 imac of booting Ben Martz
1999-05-11 8:36 ` Joel Klecker
1999-05-11 15:22 ` David Edelsohn
1999-05-11 16:47 ` Geert Uytterhoeven
1999-05-11 17:44 ` Anyone playing with Darwin 0.2 binary yet? Kevin B. Hendricks
1999-05-11 18:47 ` Nathan Ingersoll
1999-05-11 21:00 ` Roger Ivie
1999-05-11 22:15 ` David A. Gatwood
[not found] ` <v04011701b35e71c158ed@[199.174.98.46]>
1999-05-12 14:50 ` New PPC/Mac features of 2.2.8? Jason Haas
1999-05-12 18:21 ` Matt Porter
1999-05-12 19:41 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199912281902.OAA25964@mal-ach.watson.ibm.com \
--to=dje@watson.ibm.com \
--cc=dhd@debian.org \
--cc=jk@espy.org \
--cc=libc-alpha@cygnus.com \
--cc=linuxppc-dev@lists.linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).