DB_THREAD support in Berkeley DB/glibc

David Edelsohn dje@watson.ibm.com
Tue Dec 28 14:28:00 GMT 1999


	The TSL_UNSET still does not look sufficient to me.  It needs to
use lwarx/stwcx as well:

#define TSL_UNSET(tsl) ({
	register tsl_t *__l = (tsl);
	register tsl_t __r1;
	__asm__ __volatile__ ("
	       sync
           10: lwarx   %0,0,%1
	       stwcx.  %2,0,%1
               bne-    10b
	       isync"
         : "=&r" (__r1) : "r" (__l), "r" (0));
        })

As I mentioned privately to David Huggins-Daines, the order I normally use
is: 1) sync, 2) perform the atomic update, 3) isync.  This ensures that
the cached copy of the memory location is consistent, performs the update,
and the ensures that no later instructions which depend on the atomicity
are moved ahead of the atomic operation.  I am not sure how that maps to
the Alpha "memory barrier" instruction as I have seen some discussion
about it on the Linux/PPC mailinglists in the past.  As long as all
threads using the macro sync first, there is should be no need to sync
after.

David


More information about the Libc-alpha mailing list