Skip to content

Commit

Permalink
Fixing test for #1036
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Dec 24, 2013
1 parent 85fe9b9 commit 76fb04e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/regressions/threads/CMakeLists.txt
Expand Up @@ -5,14 +5,14 @@
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

set(tests
block_os_threads
block_os_threads_1036
resume_priority
thread_rescheduling
thread_suspend_pending
thread_suspend_duration
)

set(block_os_threads_PARAMETERS THREADS_PER_LOCALITY 4)
set(block_os_threads_1036_PARAMETERS THREADS_PER_LOCALITY 4)
set(thread_rescheduling_PARAMETERS THREADS_PER_LOCALITY 4)
set(thread_suspend_pending_PARAMETERS THREADS_PER_LOCALITY 1)
set(thread_suspend_duration_PARAMETERS THREADS_PER_LOCALITY 1)
Expand Down
@@ -1,12 +1,18 @@
// Copyright (c) 2011-2012 Bryce Adelstein-Lelbach
// Copyright (c) 2011-2013 Bryce Adelstein-Lelbach
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// This test demonstrates the issue described in #1036: Scheduler hangs when
// user code attempts to "block" OS-threads

#include <hpx/config.hpp>
#include <hpx/hpx_init.hpp>
#include <hpx/util/high_resolution_timer.hpp>
#include <hpx/runtime/threads/thread_helpers.hpp>
#include <hpx/runtime/threads/topology.hpp>

#include <boost/assign/std/vector.hpp>

///////////////////////////////////////////////////////////////////////////////
void blocker(
Expand All @@ -24,16 +30,15 @@ void blocker(
volatile int i = 0;
boost::uint64_t delay = 100;

int hpx_main(
boost::program_options::variables_map& vm
)
int hpx_main()
{
{
///////////////////////////////////////////////////////////////////////
// Block all other OS threads.
boost::atomic<bool> started(false);

for (boost::uint64_t i = 0; i < (hpx::get_os_thread_count() - 1); ++i)
boost::uint64_t num_threads = hpx::get_os_thread_count() - 1;
for (boost::uint64_t j = 0; j != num_threads; ++j)
{
boost::atomic<bool> entered(false);

Expand Down Expand Up @@ -82,8 +87,14 @@ int main(
, "time in micro-seconds for the delay loop")
;

// We force this test to use all available threads by default.
using namespace boost::assign;
std::vector<std::string> cfg;
cfg += "hpx.os_threads=" +
boost::lexical_cast<std::string>(hpx::threads::hardware_concurrency());

// Initialize and run HPX.
return hpx::init(cmdline, argc, argv);
return hpx::init(cmdline, argc, argv, cfg);
}


0 comments on commit 76fb04e

Please sign in to comment.