Index: trunk/include/sh_pthread.h
===================================================================
--- trunk/include/sh_pthread.h	(revision 317)
+++ trunk/include/sh_pthread.h	(revision 320)
@@ -23,11 +23,20 @@
 	do {                                                               \
                 int oldtype;                                               \
+		int executeStack = 1;                                      \
 		pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);  \
                 pthread_cleanup_push(sh_pthread_mutex_unlock, (void*)&(M));\
                 pthread_mutex_lock(&(M))
 
+#define SH_MUTEX_TRYLOCK(M)						   \
+	do {                                                               \
+                int oldtype;                                               \
+		int executeStack = 0;                                      \
+		pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);  \
+                pthread_cleanup_push(sh_pthread_mutex_unlock, (void*)&(M));\
+                pthread_mutex_trylock(&(M));                               \
+		executeStack = 1
 
 #define SH_MUTEX_UNLOCK(M)						   \
-		pthread_cleanup_pop(1);                                    \
+		pthread_cleanup_pop(executeStack);                         \
                 pthread_setcanceltype(oldtype, NULL);                      \
 	} while (0)
@@ -147,4 +156,5 @@
 #define SH_MUTEX_EXTERN(M)			extern void *SH_MUTEX_DUMMY_ ## M
 #define SH_MUTEX_LOCK(M)			((void)0)
+#define SH_MUTEX_TRYLOCK(M)			((void)0)
 #define SH_MUTEX_UNLOCK(M)			((void)0)
 #define SH_MUTEX_LOCK_UNSAFE(M)			((void)0)
