IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10896


Ignore:
Timestamp:
Jan 3, 2007, 12:25:33 PM (19 years ago)
Author:
jhoblitt
Message:

remove psMemBlock.refCounterMutex as it does not work around the need for the end user to implement their own thread synchronization. Removing this field saves 24 bytes on x86/Linux and 40 bytes (!!!) on amd64/Linux PER mem block.

Location:
branches/jch-memory/psLib/src/sys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/jch-memory/psLib/src/sys/psMemory.c

    r10895 r10896  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.88.2.8 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2007-01-03 22:07:23 $
     10*  @version $Revision: 1.88.2.9 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2007-01-03 22:25:33 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    363363        *(psPtr*)&ptr->endblock = P_PS_MEMMAGIC;
    364364        ptr->userMemorySize = size;
    365         if (safeThreads) {
    366             pthread_mutex_init(&ptr->refCounterMutex, NULL);
    367         }
    368     }
     365    }
     366
    369367    // increment the memory id safely.
    370368    MUTEX_LOCK(&memBlockListMutex);
     
    561559    }
    562560
    563     MUTEX_LOCK(&ptr2->refCounterMutex);
    564561    refCount = ptr2->refCounter;
    565     MUTEX_UNLOCK(&ptr2->refCounterMutex);
    566562
    567563    return refCount;
     
    585581    }
    586582
    587     MUTEX_LOCK(&ptr->refCounterMutex);
    588583    ptr->refCounter++;
    589     MUTEX_UNLOCK(&ptr->refCounterMutex);
    590584
    591585    // Did the user ask to be informed about this allocation?
     
    618612    }
    619613
    620     MUTEX_LOCK(&ptr->refCounterMutex);
    621614    ptr->refCounter = count;
    622     MUTEX_UNLOCK(&ptr->refCounterMutex);
    623615
    624616    if (count < 1) {
     
    650642    }
    651643
    652     MUTEX_LOCK(&ptr->refCounterMutex);
    653 
    654644    if (ptr->refCounter > 1) {
    655645        ptr->refCounter--;                 // multiple references, just decrement the count.
    656         MUTEX_UNLOCK(&ptr->refCounterMutex);
    657 
    658646    } else {
    659         MUTEX_UNLOCK(&ptr->refCounterMutex);
    660 
    661647        if (ptr->freeFunc != NULL) {
    662648            ptr->freeFunc(vptr);
  • branches/jch-memory/psLib/src/sys/psMemory.h

    r10884 r10896  
    1212 *  @ingroup MemoryManagement
    1313 *
    14  *  @version $Revision: 1.61.2.1 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2007-01-03 03:36:38 $
     14 *  @version $Revision: 1.61.2.2 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2007-01-03 22:25:33 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7474    const char *file;                  ///< set from __FILE__ in e.g. p_psAlloc
    7575    const unsigned int lineno;         ///< set from __LINE__ in e.g. p_psAlloc
    76     pthread_mutex_t refCounterMutex;   ///< mutex to ensure exclusive access to reference counter
    7776    psReferenceCount refCounter;       ///< how many times pointer is referenced
    7877    bool persistent;                   ///< marks if this non-user persistent data like error stack, etc.
Note: See TracChangeset for help on using the changeset viewer.