Re: [Dpcl-develop] Re: Using 'diag' test -SEGV problem
Brought to you by:
dpcl-admin,
dwootton
From: Steve C. <sl...@sg...> - 2004-06-08 16:39:11
|
Hi, Dave. The non-deterministic SEGV problem disappears with the new (volatile) versions of 'safe_fetch' and 'check_lock'. The newer version of 'check_lock' is not necessary but is more elegant than my original hack. So, the SEGV symptom goes away. Corrupt memory is no longer an issue. Of course you need Bills original fixes to 'ShmManager.C' to even expose this problem. Without the older 'ShmManager.C' fixes the message queueing is not stressed because messages are thrown away by the zillions. SteveC - SGI > > Steve > Do these new locking functions help with your problem? Do the symptoms > change when using them? If so, how? > I have had limited time to look at your info from last week, but may have > some time tomorrow if the problem persists. > > Dave > > > > Steve Collins <sl...@sg...> > Sent by: dpc...@ww... > 06/08/2004 09:11 AM > > To > dpc...@ww... > cc > sl...@sg... > Subject > [Dpcl-develop] Re: Using 'diag' test -SEGV problem > > > > > > > > The ia64 locking primitives 'safe_fetch' and 'check_lock', it turns out, > also require 'memory fence' protection similar to that already in the > 'check_lock' routine. It was thought some months ago that simple loads > and > stores would work for 'safe_fetch' and 'check_lock'. Not so. Sigh. So > courtesy of Bill Hachfeld (SGI), here are more accurate versions of > 'safe_fetch' and 'clear_lock'. Bill also has developed a macro version of > the previous iA-64 assembler version of 'check_lock' which requires less > maintenance but provides no more functionality than the previous ia64 > assembler version. > > SteveC - SGI > Compilers/Tools > > New 'locking primitives' for shared memory: > > > #include <asm/system.h> > > > > /** Pointer to an atomically-accessed integer. */ > typedef int* atomic_p; > > > > /** > * Conditionally updates a single word variable atomically. > * > * The _check_lock subroutine performs an atomic (uninterruptible) > sequence of > * operations. The compare_and_swap subroutine is similar, but does not > issue > * synchronization instructions and therefore is inappropriate for > updating > * lock words. > * > * @note The word variable must be aligned on a full word boundary. > * > * @sa http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/libs/ > * basetrf1/_check_lock.htm > * > * @param word_addr Specifies the address of the single word variable. > * @param old_val Specifies the old value to be checked against the > value > * of the single word variable. > * @param new_val Specifies the new value to be conditionally > assigned to > * the single word variable. > * @return "FALSE" indicates that the single word variable was > equal > * to the old value and has been set to the new value. > * "TRUE" indicates that the single word variable was > not > * equal to the old value and has been left unchanged. > */ > int _check_lock(atomic_p word_addr, int old_val, int new_val) > { > volatile int* addr = (volatile int*)word_addr; > int prev_val = cmpxchg_acq(addr, old_val, new_val); > return prev_val != old_val; > } > > /** > * Reads the value of a single word variable protected by a lock. > * > * The _safe_fetch subroutine safely reads and returns a single word value > that > * is protected by a lock. This subroutine is used to read protected data > before > * releasing the lock word with the _clear_lock subroutine. If _safe_fetch > is > * not used, instructions that access data just before a lock release > could > * actually before performed after the lock release. > * > * @note The word variable must be aligned on a full word boundary. > * > * @sa http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/libs/ > * basetrf2/_safe_fetch.htm > * > * @param word_addr Specifies the address of the single word variable. > * @return This subroutine returns the value of the single > word > * variable. > */ > int _safe_fetch(atomic_p word_addr) > { > volatile int* addr = (volatile int*)word_addr; > return *addr; > } > > > > /** > * Stores a value in a single word variable atomically. > * > * The _clear_lock subroutine performs an atomic (uninterruptible) > sequence of > * operations. > * > * @note The word variable must be aligned on a full word boundary. > * > * @sa http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/libs/ > * basetrf1/_clear_lock.htm > * > * @param word_addr Specifies the address of the single word variable. > * @param val Specifies the value to store in the single word > variable. > */ > void _clear_lock(atomic_p word_addr, int val) > { > volatile int* addr = (volatile int*)word_addr; > *addr = val; > } > > _______________________________________________ > Dpcl-develop mailing list > Dpc...@ww... > http://www-124.ibm.com/developerworks/oss/mailman/listinfo/dpcl-develop > > |