From 81f3b0485861c06a210a270f5ddae2ed9d1a4f78 Mon Sep 17 00:00:00 2001 From: bangerth Date: Sat, 27 Nov 2010 00:08:52 +0000 Subject: [PATCH] Add a new test that currently deadlocks. git-svn-id: https://svn.dealii.org/trunk@22863 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/task_09.cc | 70 ++++++++++++++++++++++++++++++++++ tests/base/task_09/cmp/generic | 2 + 2 files changed, 72 insertions(+) create mode 100644 tests/base/task_09.cc create mode 100644 tests/base/task_09/cmp/generic diff --git a/tests/base/task_09.cc b/tests/base/task_09.cc new file mode 100644 index 0000000000..ef21af74b3 --- /dev/null +++ b/tests/base/task_09.cc @@ -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 +#include +#include + +#include +#include + + +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