]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Release mutex on the same thread that acquired it, to satisfy POSIX requirements.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 8 Oct 2013 12:46:17 +0000 (12:46 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 8 Oct 2013 12:46:17 +0000 (12:46 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@31170 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/thread_validity_08.cc

index 2f878089b6c192253bd21c5e1d4f84ae356141b2..2f4bbe18feccef773380495ab9ec59e5c4a859fd 100644 (file)
@@ -31,7 +31,11 @@ int spin_lock = 0;
 
 void worker ()
 {
+  // wait for the mutex to make sure the main
+  // thread has already moved on. we can immediately
+  // release the mutex again.
   mutex.acquire ();
+  mutex.release ();
   deallog << "OK." << std::endl;
   spin_lock = 1;
 }
@@ -70,8 +74,4 @@ int main()
   // wait for thread to finish
   while (spin_lock == 0)
     ;
-
-  // release the lock that the thread
-  // acquired to avoid pthread errors
-  mutex.release ();
 }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.