]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add a new test that currently deadlocks.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 27 Nov 2010 00:08:52 +0000 (00:08 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 27 Nov 2010 00:08:52 +0000 (00:08 +0000)
git-svn-id: https://svn.dealii.org/trunk@22863 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/task_09.cc [new file with mode: 0644]
tests/base/task_09/cmp/generic [new file with mode: 0644]

diff --git a/tests/base/task_09.cc b/tests/base/task_09.cc
new file mode 100644 (file)
index 0000000..ef21af7
--- /dev/null
@@ -0,0 +1,70 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2009, 2010 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//-----------------------------------------------------------------------------
+
+// we used to synchronise child tasks with the one that spawned it by
+// using a mutex, but this could lead to deadlocks if there are more
+// tasks than processors available, see the emails on the mailing
+// lists in late nov 2010.
+//
+// this test verifies that we no longer deadlock
+
+#include "../tests.h"
+#include <iomanip>
+#include <fstream>
+#include <unistd.h>
+
+#include <base/thread_management.h>
+#include <base/multithread_info.h>
+
+
+void test ()
+{
+  sleep (1);
+}
+
+
+void outer ()
+{
+                                  // wait for some time to make sure
+                                  // that really all outer tasks have
+                                  // been started, then start a bunch
+                                  // of new tasks and wait for them
+                                  // to finish. it used to be that
+                                  // the join() function used a mutex
+                                  // which could only be acquired
+                                  // once the spawned task has
+                                  // finished, but since we already
+                                  // have so many tasks running at
+                                  // this point, the children never
+                                  // get to run and so never release
+                                  // the mutex that we try to acquire
+                                  // in join()
+  sleep (1);
+
+  Threads::new_task (test).join();
+}
+
+
+
+int main()
+{
+  std::ofstream logfile("task_09/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  for (unsigned int i=0; i<multithread_info.n_cpus*2; ++i)
+    Threads::new_task (outer);
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/base/task_09/cmp/generic b/tests/base/task_09/cmp/generic
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK

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.