improved performance

This commit is contained in:
Jeff Hill
2000-11-08 03:52:18 +00:00
parent 2ded135da9
commit 4784b73a9f
39 changed files with 2480 additions and 2589 deletions

View File

@@ -19,7 +19,8 @@
#include "iocinf.h"
recvProcessThread::recvProcessThread (cac *pcacIn) :
osiThread ( "CAC-recv-process", threadGetStackSize (threadStackSmall), threadPriorityMedium ),
osiThread ( "CAC-recv-process", threadGetStackSize (threadStackSmall),
pcacIn->getInitializingThreadsPriority () ),
pcac ( pcacIn ),
enableRefCount ( 0u ),
blockingForCompletion ( 0u ),
@@ -41,18 +42,25 @@ void recvProcessThread::entryPoint ()
SEVCHK ( status, "attaching to client context in recv process thread" );
while ( ! this->shutDown ) {
this->mutex.lock ();
if ( this->enableRefCount ) {
this->processing = true;
{
osiAutoMutex autoMutex ( this->mutex );
if ( this->enableRefCount ) {
this->processing = true;
}
}
this->mutex.unlock ();
if ( this->processing ) {
pcac->processRecvBacklog ();
}
this->processing = false;
if ( this->blockingForCompletion ) {
bool signalNeeded;
{
osiAutoMutex autoMutex ( this->mutex );
this->processing = false;
signalNeeded = this->blockingForCompletion > 0u;
}
if ( signalNeeded ) {
this->processingDone.signal ();
}
@@ -71,11 +79,12 @@ void recvProcessThread::enable ()
{
unsigned copy;
this->mutex.lock ();
assert ( this->enableRefCount < UINT_MAX );
copy = this->enableRefCount;
this->enableRefCount++;
this->mutex.unlock ();
{
osiAutoMutex autoMutex ( this->mutex );
assert ( this->enableRefCount < UINT_MAX );
copy = this->enableRefCount;
this->enableRefCount++;
}
if ( copy == 0u ) {
this->recvActivity.signal ();
@@ -84,31 +93,41 @@ void recvProcessThread::enable ()
void recvProcessThread::disable ()
{
bool waitNeeded;
bool wakeupNeeded;
this->mutex.lock ();
assert ( this->enableRefCount != 0u );
this->enableRefCount--;
if ( this->enableRefCount == 0u && this->processing ) {
waitNeeded = true;
this->blockingForCompletion++;
}
else {
waitNeeded = false;
}
this->mutex.unlock ();
{
osiAutoMutex autoMutex ( this->mutex );
if ( waitNeeded ) {
while ( this->processing ) {
this->processingDone.wait ();
if ( ! this->processing ) {
assert ( this->enableRefCount != 0u );
this->enableRefCount--;
return;
}
this->mutex.lock ();
this->blockingForCompletion--;
this->mutex.unlock ();
if ( this->blockingForCompletion ) {
this->processingDone.signal ();
else {
this->blockingForCompletion++;
}
}
while ( true ) {
this->processingDone.wait ();
{
osiAutoMutex autoMutex ( this->mutex );
if ( ! this->processing ) {
assert ( this->enableRefCount > 0u );
this->enableRefCount--;
assert ( this->blockingForCompletion > 0u );
this->blockingForCompletion--;
wakeupNeeded = this->blockingForCompletion > 0u;
break;
}
}
}
if ( wakeupNeeded ) {
this->processingDone.signal ();
}
}
void recvProcessThread::signalActivity ()
@@ -118,7 +137,7 @@ void recvProcessThread::signalActivity ()
void recvProcessThread::show ( unsigned level ) const
{
this->mutex.lock ();
osiAutoMutex autoMutex ( this->mutex );
printf ( "CA receive processing thread at %p state=%s\n",
this, this->processing ? "busy" : "idle");
if ( level > 0u ) {
@@ -139,5 +158,4 @@ void recvProcessThread::show ( unsigned level ) const
printf ( "mutex:\n" );
this->mutex.show ( level - 3u );
}
this->mutex.unlock ();
}