|
/* Using CMPSW to implement an InterlockedIncrement( ) function. */
/* this is a lot faster than LOCKSL, Inc value, UNLOCKSL. */
DCL SPCPTR pGlobalCount AUTO ;
DCL DD nGlobalCount BIN(2) BAS(pGlobalCount) ;
DCL DD nWasCount, nIncCount BIN(2) AUTO ;
BgnInc:
CPYNV nWasCount, nGlobalCount ;
ADDN nIncCount, nWasCount, 1 ;
/* If Was and Global are equal ( no other thread has gotten to Global ), */
/* set Global = Inc. Otherwise, set Was = Inc. */
CMPSW nWasCount, nGlobalCount, nIncCount ;
/* ( should not CMPSW be called CMPCHG ( compare and chg ) ? */
/* Was and Global were not equal at CMPSW time. */
/* Someone else got to Global since "CPYNV Was, Global". */
/* Branch back and try again. */
CMPNV(B) nWasCount, nIncCount / EQ(BgnInc) ;
EndInc:
/* return with nWasCount and nIncCount. */
/* the machine guarantees that this code set Global = Inc. */
Thanks for the answers Larry.
Steve Richter
+---
| This is the MI Programmers Mailing List!
| To submit a new message, send your mail to MI400@midrange.com.
| To subscribe to this list send email to MI400-SUB@midrange.com.
| To unsubscribe from this list send email to MI400-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: dr2@cssas400.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.