Index: /trunk/Ohana/src/opihi/lib.shell/VariableOps.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/VariableOps.c	(revision 18731)
+++ /trunk/Ohana/src/opihi/lib.shell/VariableOps.c	(revision 18732)
@@ -129,10 +129,16 @@
   ALLOCATE (local, char, strlen(name) + strlen(MacroName) + 2);
   sprintf (local, "%s.%s", MacroName, name);
+
+  /* need to use a mutex to prevent another thread from misleading on size of Nvariables */
+  pthread_mutex_lock (&mutex);
+
   for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */
     if (!strcmp(local, variables[i].name)) {
+      pthread_mutex_unlock (&mutex);
       free (local);
       return (variables[i].value);
     }
   }
+  pthread_mutex_unlock (&mutex);
   free (local);
   return (NULL);
@@ -161,10 +167,15 @@
   if (local != NULL) return (local);
 
+  /* need to use a mutex to prevent another thread from misleading on size of Nvariables */
+  pthread_mutex_lock (&mutex);
+
   /* look for global variable */
   for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */
     if (!strcmp(name, variables[i].name)) {
+      pthread_mutex_unlock (&mutex);
       return (variables[i].value);
     }
   }
+  pthread_mutex_unlock (&mutex);
   return (NULL);
 }
@@ -238,4 +249,7 @@
 
   int i, j;
+
+  /* need to use a mutex to prevent two threads from simultaneously modifying Nvariables */
+  pthread_mutex_lock (&mutex);
 
   for (i = 0; i < Nvariables; i++) {
@@ -248,7 +262,9 @@
       Nvariables --;
       REALLOCATE (variables, Variable, MAX (Nvariables, 1));
-      return (TRUE);
-    }
-  }
+      pthread_mutex_unlock (&mutex);
+      return (TRUE);
+    }
+  }
+  pthread_mutex_unlock (&mutex);
   return (FALSE);
 }
@@ -258,7 +274,14 @@
   int i;
 
-  for (i = 0; i < Nvariables; i++) {
-    if (!strcmp (name, variables[i].name)) return (TRUE);
-  }
+  /* need to use a mutex to prevent another thread from misleading on size of Nvariables */
+  pthread_mutex_lock (&mutex);
+
+  for (i = 0; i < Nvariables; i++) {
+    if (!strcmp (name, variables[i].name)) {
+      pthread_mutex_unlock (&mutex);
+      return (TRUE);
+    }
+  }
+  pthread_mutex_unlock (&mutex);
   return (FALSE);
 }
@@ -273,7 +296,12 @@
   }
 
+  /* need to use a mutex to prevent another thread from misleading on size of Nvariables */
+  pthread_mutex_lock (&mutex);
+
   for (i = 0; i < Nvariables; i++) {
     gprint (GP_ERR, "%s = %s\n", variables[i].name, variables[i].value);
   }
+
+  pthread_mutex_unlock (&mutex);
   return;
 }
