From: Nicholas Nethercote Date: Mon, 13 Sep 2004 20:51:10 +0000 (+0000) Subject: All newlines are borked -- fix. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3247cc7a863144ab825e73d9b33f06057059177e;p=thirdparty%2Fvalgrind.git All newlines are borked -- fix. MERGED FROM HEAD git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_2_2_0_BRANCH@2718 --- diff --git a/helgrind/tests/deadlock.c b/helgrind/tests/deadlock.c index 81da0b4c29..1142f5cfe9 100644 --- a/helgrind/tests/deadlock.c +++ b/helgrind/tests/deadlock.c @@ -1 +1,43 @@ -/* Simple possible deadlock */ #include static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER; static void *t1(void *v) { pthread_mutex_lock(&m1); pthread_mutex_lock(&m2); pthread_mutex_unlock(&m1); pthread_mutex_unlock(&m2); return 0; } static void *t2(void *v) { pthread_mutex_lock(&m2); pthread_mutex_lock(&m1); pthread_mutex_unlock(&m1); pthread_mutex_unlock(&m2); return 0; } int main() { pthread_t a, b; /* prevent spurious messages from the dynamic linker */ pthread_mutex_lock(&m1); pthread_mutex_unlock(&m1); pthread_create(&a, NULL, t1, NULL); pthread_create(&b, NULL, t2, NULL); pthread_join(a, NULL); pthread_join(b, NULL); return 0; } \ No newline at end of file +/* Simple possible deadlock */ +#include + +static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER; + +static void *t1(void *v) +{ + pthread_mutex_lock(&m1); + pthread_mutex_lock(&m2); + pthread_mutex_unlock(&m1); + pthread_mutex_unlock(&m2); + + return 0; +} + +static void *t2(void *v) +{ + pthread_mutex_lock(&m2); + pthread_mutex_lock(&m1); + pthread_mutex_unlock(&m1); + pthread_mutex_unlock(&m2); + + return 0; +} + +int main() +{ + pthread_t a, b; + + /* prevent spurious messages from the dynamic linker */ + pthread_mutex_lock(&m1); + pthread_mutex_unlock(&m1); + + pthread_create(&a, NULL, t1, NULL); + pthread_create(&b, NULL, t2, NULL); + + pthread_join(a, NULL); + pthread_join(b, NULL); + + return 0; +} +