summaryrefslogtreecommitdiff
path: root/tests/mutex2.c
diff options
context:
space:
mode:
authorrpj <rpj>1999-02-20 03:06:22 +0000
committerrpj <rpj>1999-02-20 03:06:22 +0000
commit949ca2ccc5c972644c70238eee7d2099a3ede1f3 (patch)
tree15c5c309b5b9f8f32e8a1b9d853ab377c09044e9 /tests/mutex2.c
parent4a30695c72d49a8d4a7c9dd7892456170eaa39d6 (diff)
1999-02-20 Ross Johnson <rpj@ise.canberra.edu.au>
* tests/mutex2.c: Test static mutex initialisation. * tests/test.h: New. Declares a table mapping error numbers to error names.
Diffstat (limited to 'tests/mutex2.c')
-rw-r--r--tests/mutex2.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/tests/mutex2.c b/tests/mutex2.c
index 224b7ea..d0885fc 100644
--- a/tests/mutex2.c
+++ b/tests/mutex2.c
@@ -1,12 +1,25 @@
+/*
+ * mutex1.c
+ *
+ * Declare a static mutex object, lock it, and then unlock it again.
+ */
+
#include <pthread.h>
+#include "test.h"
-pthread_mutex_t mutex1;
-
+pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
+
main()
{
- pthread_mutex_init(&mutex1, NULL);
- pthread_mutex_trylock(&mutex1);
- pthread_mutex_unlock(&mutex1);
+ int result;
+
+ result = pthread_mutex_trylock(&mutex1);
+ printf("pthread_mutex_trylock returned %s\n", error_string[result]);
+
+ if (result == 0)
+ {
+ pthread_mutex_unlock(&mutex1);
+ }
return 0;
}