From 57143c27c740b7aa40d71b6c3271aabd0f0e06b9 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 7 Sep 2000 01:41:31 +0000 Subject: [PATCH] installed --- src/ca/cacPrivateListOfIO.cpp | 81 +++++++++++++++++++++++++++++++++ src/ca/claimMsgCache_IL.h | 6 +-- src/ca/ioCounter.cpp | 85 +++++++++++++++++++++++++++++++++++ src/ca/ioCounter_IL.h | 67 +++++++++++++++++++++++++++ 4 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 src/ca/cacPrivateListOfIO.cpp create mode 100644 src/ca/ioCounter.cpp create mode 100644 src/ca/ioCounter_IL.h diff --git a/src/ca/cacPrivateListOfIO.cpp b/src/ca/cacPrivateListOfIO.cpp new file mode 100644 index 000000000..614a23f7f --- /dev/null +++ b/src/ca/cacPrivateListOfIO.cpp @@ -0,0 +1,81 @@ + +/* + * $Id$ + * + * + * L O S A L A M O S + * Los Alamos National Laboratory + * Los Alamos, New Mexico 87545 + * + * Copyright, 1986, The Regents of the University of California. + * + * + * Author Jeffrey O. Hill + * johill@lanl.gov + * 505 665 1831 + */ + +#include "iocinf.h" + +cacPrivateListOfIO::cacPrivateListOfIO ( cac &cacIn ) : + cacCtx ( cacIn ) +{ +} + +// Destroy all IO blocks attached. +// Care is taken here not to hold the lock while +// sending a subscription delete message (which +// would result in deadlocks) +void cacPrivateListOfIO::destroyAllIO () +{ + while ( true ) { + unsigned id; + bool done; + + this->cacCtx.cacPrivateListOfIOPrivate::mutex.lock (); + { + baseNMIU *pNMIU = this->eventq.first (); + if ( pNMIU ) { + id = pNMIU->getId (); + done = false; + } + else { + id = UINT_MAX; + done = true; + } + } + this->cacCtx.cacPrivateListOfIOPrivate::mutex.unlock (); + + if ( done ) { + break; + } + // care is taken to not hold a lock when + // executing this + this->cacCtx.ioDestroy ( id ); + } +} + +// resubscribe for monitors from this channel +void cacPrivateListOfIO::subscribeAllIO () +{ + this->cacCtx.cacPrivateListOfIOPrivate::mutex.lock (); + tsDLIterBD < baseNMIU > iter = this->eventq.first (); + while ( iter.valid () ) { + iter->subscriptionMsg (); + iter++; + } + this->cacCtx.cacPrivateListOfIOPrivate::mutex.unlock (); +} + +// cancel IO operations and monitor subscriptions +void cacPrivateListOfIO::disconnectAllIO ( const char *pHostName ) +{ + this->cacCtx.cacPrivateListOfIOPrivate::mutex.lock (); + tsDLIterBD < baseNMIU > iter = this->eventq.first (); + while ( iter.valid () ) { + tsDLIterBD < baseNMIU > next = iter.itemAfter (); + iter->disconnect ( pHostName ); + iter = next; + } + this->cacCtx.cacPrivateListOfIOPrivate::mutex.unlock (); +} diff --git a/src/ca/claimMsgCache_IL.h b/src/ca/claimMsgCache_IL.h index 3600c9758..d92d3df32 100644 --- a/src/ca/claimMsgCache_IL.h +++ b/src/ca/claimMsgCache_IL.h @@ -23,7 +23,7 @@ inline claimMsgCache::~claimMsgCache () } } -inline int claimMsgCache::deliverMsg ( tcpiiu &iiu ) +inline int claimMsgCache::deliverMsg ( netiiu &iiu ) { if ( v44 ) { return iiu.createChannelRequest ( this->clientId, this->pStr, this->currentStrLen ); @@ -33,7 +33,7 @@ inline int claimMsgCache::deliverMsg ( tcpiiu &iiu ) } } -inline bool claimMsgCache::channelMatches ( class nciu &chan ) +inline void claimMsgCache::connectChannel ( cac & cacRef ) { - return chan.id == this->clientId; + cacRef.connectChannel ( this->clientId ); } diff --git a/src/ca/ioCounter.cpp b/src/ca/ioCounter.cpp new file mode 100644 index 000000000..306673838 --- /dev/null +++ b/src/ca/ioCounter.cpp @@ -0,0 +1,85 @@ + +/* + * $Id$ + * + * + * L O S A L A M O S + * Los Alamos National Laboratory + * Los Alamos, New Mexico 87545 + * + * Copyright, 1986, The Regents of the University of California. + * + * + * Author Jeffrey O. Hill + * johill@lanl.gov + * 505 665 1831 + */ + +#include "iocinf.h" + +void ioCounter::decrementOutstandingIO () +{ + bool signalNeeded; + this->mutex.lock (); + if ( this->pndrecvcnt > 0u ) { + this->pndrecvcnt--; + if ( this->pndrecvcnt == 0u ) { + signalNeeded = true; + } + else { + signalNeeded = false; + } + } + else { + signalNeeded = true; + } + this->mutex.unlock (); + + if ( signalNeeded ) { + this->ioDone.signal (); + } +} + +void ioCounter::decrementOutstandingIO ( unsigned seqNumber ) +{ + bool signalNeeded; + + this->mutex.lock (); + if ( this->readSeq == seqNumber ) { + if ( this->pndrecvcnt > 0u ) { + this->pndrecvcnt--; + if ( this->pndrecvcnt == 0u ) { + signalNeeded = true; + } + else { + signalNeeded = false; + } + } + else { + signalNeeded = true; + } + } + else { + signalNeeded = false; + } + this->mutex.unlock (); + + if ( signalNeeded ) { + this->ioDone.signal (); + } +} + +void ioCounter::showOutstandingIO ( unsigned level ) const +{ + printf ( "ioCounter at %p\n", this ); + printf ( "\tthere are %u unsatisfied IO operations blocking ca_pend_io()\n", + this->pndrecvcnt ); + if ( level > 0u ) { + printf ( "\tthe current read sequence number is %u\n", + this->readSeq ); + } + if ( level > 1u ) { + printf ( "IO done event:\n"); + this->ioDone.show ( level - 2u ); + } +} diff --git a/src/ca/ioCounter_IL.h b/src/ca/ioCounter_IL.h new file mode 100644 index 000000000..121950b39 --- /dev/null +++ b/src/ca/ioCounter_IL.h @@ -0,0 +1,67 @@ + + +/* + * $Id$ + * + * + * L O S A L A M O S + * Los Alamos National Laboratory + * Los Alamos, New Mexico 87545 + * + * Copyright, 1986, The Regents of the University of California. + * + * + * Author Jeffrey O. Hill + * johill@lanl.gov + * 505 665 1831 + */ + +inline ioCounter::ioCounter () : pndrecvcnt ( 0u ), readSeq ( 0u ) +{ +} + +inline void ioCounter::incrementOutstandingIO () +{ + this->mutex.lock (); + if ( this->pndrecvcnt < UINT_MAX ) { + this->pndrecvcnt++; + } + this->mutex.unlock (); +} + +inline void ioCounter::lockOutstandingIO () const +{ + this->mutex.lock (); +} + +inline void ioCounter::unlockOutstandingIO () const +{ + this->mutex.unlock (); +} + +inline unsigned ioCounter::readSequenceOfOutstandingIO () const +{ + return this->readSeq; +} + +inline unsigned ioCounter::currentOutstandingIOCount () const +{ + return this->pndrecvcnt; +} + +inline void ioCounter::waitForCompletionOfIO ( double delaySec ) +{ + this->ioDone.wait ( delaySec ); +} + +inline void ioCounter::cleanUpOutstandingIO () +{ + this->mutex.lock (); + + this->readSeq++; + this->pndrecvcnt = 0u; + + this->mutex.unlock (); +} + +