Index: trunk/psLib/src/sys/Makefile.am
===================================================================
--- trunk/psLib/src/sys/Makefile.am	(revision 19034)
+++ trunk/psLib/src/sys/Makefile.am	(revision 19056)
@@ -41,4 +41,5 @@
 	psLogMsg.h     \
 	psMemory.h     \
+	psMutex.h      \
 	psSlurp.h      \
 	psString.h     \
Index: trunk/psLib/src/sys/psMutex.h
===================================================================
--- trunk/psLib/src/sys/psMutex.h	(revision 19056)
+++ trunk/psLib/src/sys/psMutex.h	(revision 19056)
@@ -0,0 +1,36 @@
+#ifndef PS_MUTEX_H
+#define PS_MUTEX_H
+
+#include <pthread.h>
+
+typedef pthread_mutex_t psMutex;        /// Mutual Exclusion using pthreads
+
+/// Initialize a mutex
+#define psMutexInit(PTR) { \
+    /* Gotta go the long way, since we can't use PTHREAD_MUTEX_INITIALIZER after we declare the variable */ \
+    pthread_mutexattr_t attr; /* Mutex attributes */ \
+    pthread_mutexattr_init(&attr); \
+    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_FAST_NP); \
+    pthread_mutex_init(&(PTR)->lock, &attr); \
+    pthread_mutexattr_destroy(&attr); \
+}
+
+/// Lock a mutex
+#define psMutexLock(PTR) \
+if (pthread_mutex_lock(&(PTR)->lock) == EINVAL) { \
+    psAbort("Cannot lock mutex on %s: not initialised", #PTR); \
+}
+
+/// Unlock a mutex
+#define psMutexUnlock(PTR) \
+if (pthread_mutex_unlock(&(PTR)->lock) == EINVAL) { \
+    psAbort("Cannot unlock mutex on %s: not initialised", #PTR); \
+}
+
+/// Destroy a mutex
+#define psMutexDestroy(PTR) \
+if (pthread_mutex_destroy(&(PTR)->lock) == EBUSY) { \
+    psAbort("Cannot destroy mutex on %s: is busy", #PTR); \
+}
+
+#endif
