Index: /branches/eam_branches/ipp-20110505/psLib/src/sys/psMemory.c
===================================================================
--- /branches/eam_branches/ipp-20110505/psLib/src/sys/psMemory.c	(revision 31578)
+++ /branches/eam_branches/ipp-20110505/psLib/src/sys/psMemory.c	(revision 31579)
@@ -40,5 +40,21 @@
 #define P_PS_MEMMAGIC (uint32_t)0xdeadbeef
 
-# define USE_SPINLOCK 1
+// The psLib memory tools require locking to manipulate the linked list which holds the memory
+// structure.  There are two major options which can be invoked, given below.  
+
+// USE_SPINLOCK replaces the mutex in this code block with a spinlock.  This might be faster in
+// some cases, but probably not enough to matter.  The disadavantages are: (1) programs would
+// need to call the function 'psMemInit' (which they currently do not in general); (2)
+// single-processor machines are poorly set up to use spinlocks; (3) not all compilers /
+// machine combinations support spinlocks.  This option is NOT recommended
+
+// USE_HARDLOCK replaces the per-memBlock locking that is the minimum required to protect the
+// psRealloc function with pure mutex locking that holds the lock during the (possibly
+// expensive) realloc call.  At this point, it does not seem clear that there is a substantial
+// gain in processing speed from using the per-memBlock locking, but more testing may reveal
+// cases where it matters.  
+
+# define USE_SPINLOCK 0
+# define USE_HARDLOCK 0
 
 # if (USE_SPINLOCK) 
@@ -110,6 +126,5 @@
 static pthread_spinlock_t memBlockListMutex;
 # else
-// static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t memBlockListMutex;
+static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
 # endif
 
@@ -118,6 +133,4 @@
 # if (USE_SPINLOCK) 
     pthread_spin_init(&memBlockListMutex, 0);
-# else
-    pthread_mutex_init(&memBlockListMutex, NULL);
 # endif
 
@@ -359,8 +372,5 @@
  **/
 
-// if HARDLOCKS is set, revert to global locking for realloc
-# define HARDLOCKS 0
-
-# if (!HARDLOCKS)
+# if (!USE_HARDLOCK)
 static int setLock = 0;
 static int clearLock = 0;
@@ -379,5 +389,5 @@
 void BLOCKLAST_LOCK () {
 
-# if (HARDLOCKS) 
+# if (USE_HARDLOCK) 
     MUTEX_LOCK(&memBlockListMutex);
 # else
@@ -413,5 +423,5 @@
 void BLOCK_LOCK (psMemBlock *memBlock, bool keepMutex) {
 
-# if (HARDLOCKS) 
+# if (USE_HARDLOCK) 
     MUTEX_LOCK(&memBlockListMutex);
 # else
@@ -451,5 +461,5 @@
 void BLOCK_UNLOCK (psMemBlock *memBlock, bool haveMutex) {
     
-# if (HARDLOCKS)
+# if (USE_HARDLOCK)
     MUTEX_UNLOCK(&memBlockListMutex);
 # else
@@ -481,5 +491,5 @@
 void BLOCKSET_LOCK (psMemBlock *memBlock, bool keepMutex) {
 
-# if (HARDLOCKS)
+# if (USE_HARDLOCK)
     MUTEX_LOCK(&memBlockListMutex);
 # else
@@ -539,5 +549,5 @@
 void BLOCKSET_UNLOCK (psMemBlock *memBlock, bool haveMutex) {
     
-# if (HARDLOCKS) 
+# if (USE_HARDLOCK) 
     MUTEX_UNLOCK(&memBlockListMutex);
 # else
Index: /branches/eam_branches/ipp-20110505/psLib/src/sys/psMemory.h
===================================================================
--- /branches/eam_branches/ipp-20110505/psLib/src/sys/psMemory.h	(revision 31578)
+++ /branches/eam_branches/ipp-20110505/psLib/src/sys/psMemory.h	(revision 31579)
@@ -146,4 +146,6 @@
 #endif // ifdef DOXYGEN
 
+// if we decide to use spinlocks for psMemory, it will be necessary to call this function at
+// the start of every psLib-based program (spinlocks do not have a static initializer)
 void psMemInit(void);
 
