Changeset 803
- Timestamp:
- May 27, 2004, 5:17:39 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 4 edited
-
sys/psMemory.c (modified) (6 diffs)
-
sys/psMemory.h (modified) (2 diffs)
-
sysUtils/psMemory.c (modified) (6 diffs)
-
sysUtils/psMemory.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psMemory.c
r648 r803 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-05- 12 19:05:02$10 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-05-28 03:17:39 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 31 31 static psMemBlock *lastMemBlockAllocated = NULL; 32 32 pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER; 33 pthread_mutex_t memIdMutex = PTHREAD_MUTEX_INITIALIZER; 33 34 34 35 /** … … 172 173 psMemoryId psMemGetId(void) 173 174 { 174 return memid + 1; 175 psMemoryId id; 176 pthread_mutex_lock(&memIdMutex); 177 id = memid + 1; 178 pthread_mutex_unlock(&memIdMutex); 179 180 return id; 175 181 } 176 182 … … 252 258 } 253 259 260 261 // increment the memory id safely. 262 pthread_mutex_lock(&memBlockListMutex); 254 263 *(psMemoryId*)&ptr->id = ++memid; 264 pthread_mutex_unlock(&memBlockListMutex); 265 255 266 ptr->file = file; 256 267 *(unsigned int*)&ptr->lineno = lineno; … … 260 271 ptr->userMemorySize = size; 261 272 *(void**)((int8_t*)(ptr+1)+size) = P_PS_MEMMAGIC; 273 ptr->previousBlock = NULL; 262 274 263 275 // need exclusive access of the memory block list now... … … 265 277 266 278 // insert the new block to the front of the memBlock linked-list 267 ptr->previousBlock = NULL;268 279 ptr->nextBlock = lastMemBlockAllocated; 269 280 if (ptr->nextBlock != NULL) { -
trunk/psLib/src/sys/psMemory.h
r768 r803 12 12 * @author Robert Lupton, Princeton University 13 13 * 14 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-05-2 4 23:03:51$14 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-05-28 03:17:39 $ 16 16 * 17 17 * @ingroup SystemGroup System Utilities … … 64 64 const char* file; ///< set from __FILE__ in e.g. p_psAlloc 65 65 const int lineno; ///< set from __LINE__ in e.g. p_psAlloc 66 psReferenceCount refCounter; ///< how many times pointer is referenced 66 // TODO: refCounter should be mutexed? 67 psReferenceCount refCounter; ///< how many times pointer is referenced 67 68 const void* endblock; ///< initialised to p_psMEMMAGIC 68 69 } -
trunk/psLib/src/sysUtils/psMemory.c
r648 r803 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-05- 12 19:05:02$10 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-05-28 03:17:39 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 31 31 static psMemBlock *lastMemBlockAllocated = NULL; 32 32 pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER; 33 pthread_mutex_t memIdMutex = PTHREAD_MUTEX_INITIALIZER; 33 34 34 35 /** … … 172 173 psMemoryId psMemGetId(void) 173 174 { 174 return memid + 1; 175 psMemoryId id; 176 pthread_mutex_lock(&memIdMutex); 177 id = memid + 1; 178 pthread_mutex_unlock(&memIdMutex); 179 180 return id; 175 181 } 176 182 … … 252 258 } 253 259 260 261 // increment the memory id safely. 262 pthread_mutex_lock(&memBlockListMutex); 254 263 *(psMemoryId*)&ptr->id = ++memid; 264 pthread_mutex_unlock(&memBlockListMutex); 265 255 266 ptr->file = file; 256 267 *(unsigned int*)&ptr->lineno = lineno; … … 260 271 ptr->userMemorySize = size; 261 272 *(void**)((int8_t*)(ptr+1)+size) = P_PS_MEMMAGIC; 273 ptr->previousBlock = NULL; 262 274 263 275 // need exclusive access of the memory block list now... … … 265 277 266 278 // insert the new block to the front of the memBlock linked-list 267 ptr->previousBlock = NULL;268 279 ptr->nextBlock = lastMemBlockAllocated; 269 280 if (ptr->nextBlock != NULL) { -
trunk/psLib/src/sysUtils/psMemory.h
r768 r803 12 12 * @author Robert Lupton, Princeton University 13 13 * 14 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-05-2 4 23:03:51$14 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-05-28 03:17:39 $ 16 16 * 17 17 * @ingroup SystemGroup System Utilities … … 64 64 const char* file; ///< set from __FILE__ in e.g. p_psAlloc 65 65 const int lineno; ///< set from __LINE__ in e.g. p_psAlloc 66 psReferenceCount refCounter; ///< how many times pointer is referenced 66 // TODO: refCounter should be mutexed? 67 psReferenceCount refCounter; ///< how many times pointer is referenced 67 68 const void* endblock; ///< initialised to p_psMEMMAGIC 68 69 }
Note:
See TracChangeset
for help on using the changeset viewer.
