summaryrefslogtreecommitdiff
path: root/tests/mutex6.c
diff options
context:
space:
mode:
authorrpj <rpj>2002-01-13 02:29:40 +0000
committerrpj <rpj>2002-01-13 02:29:40 +0000
commit30a1e9738593302fa26e0a668f517bc7f5800190 (patch)
treeb7379d358ab465e2c2c57864699c91b9055fc9fd /tests/mutex6.c
parent0fee04f5eb2d9c1c484281afbc2b24278567a179 (diff)
* attr.c (pthread_attr_setscope): Fix struct pointer
indirection error introduced 2002-01-04. (pthread_attr_getscope): Likewise. * pthread.dsp (SOURCE): Add missing source files. ./tests/: * exception3.c (main): Shorten wait time. * mutex7.c: New test. * mutex7n.c: New test. * mutex7e.c: New test. * mutex7r.c: New test. * mutex6.c: Modified to avoid leaving the locked mutex around on exit.
Diffstat (limited to 'tests/mutex6.c')
-rw-r--r--tests/mutex6.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/mutex6.c b/tests/mutex6.c
index 5cd6d46..dc14c46 100644
--- a/tests/mutex6.c
+++ b/tests/mutex6.c
@@ -45,10 +45,10 @@ void * locker(void * arg)
{
assert(pthread_mutex_lock(&mutex) == 0);
lockCount++;
- assert(pthread_mutex_lock(&mutex) != 0);
+
+ /* Should wait here (deadlocked) */
+ assert(pthread_mutex_lock(&mutex) == 0);
lockCount++;
- Sleep(1000);
- assert(pthread_mutex_unlock(&mutex) == 0);
assert(pthread_mutex_unlock(&mutex) == 0);
return 0;
@@ -63,10 +63,20 @@ main()
assert(pthread_create(&t, NULL, locker, NULL) == 0);
- Sleep(2000);
+ Sleep(1000);
assert(lockCount == 1);
+ /*
+ * Should succeed even though we don't own the lock
+ * because FAST mutexes don't check ownership.
+ */
+ assert(pthread_mutex_unlock(&mutex) == 0);
+
+ Sleep (1000);
+
+ assert(lockCount == 2);
+
exit(0);
/* Never reached */