From 02cd43b565615593f90bd08eb4e718a6ee649661 Mon Sep 17 00:00:00 2001 From: eb Date: Tue, 28 Aug 2007 05:59:31 +0000 Subject: [PATCH] Kludged around hang in hier_block2. Merged -r6189:6191 from eb/fg into trunk. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@6193 221aa14e-8319-0410-a670-987f0aec2ac5 --- .../src/lib/runtime/gr_scheduler_thread.cc | 6 ++++- .../runtime/gr_single_threaded_scheduler.cc | 10 +++++++- .../runtime/gr_single_threaded_scheduler.h | 2 +- .../src/lib/runtime/gr_top_block_impl.cc | 2 +- .../src/lib/runtime/qa_gr_top_block.cc | 23 ++++++++++++++----- .../src/lib/runtime/qa_gr_top_block.h | 2 +- 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/gnuradio-core/src/lib/runtime/gr_scheduler_thread.cc b/gnuradio-core/src/lib/runtime/gr_scheduler_thread.cc index 9cce5eae..16f36ac5 100644 --- a/gnuradio-core/src/lib/runtime/gr_scheduler_thread.cc +++ b/gnuradio-core/src/lib/runtime/gr_scheduler_thread.cc @@ -45,6 +45,9 @@ gr_scheduler_thread::~gr_scheduler_thread() void gr_scheduler_thread::start() { + if (GR_SCHEDULER_THREAD_DEBUG) + std::cout << "gr_scheduler_thread::start() " + << this << std::endl; start_undetached(); } @@ -70,6 +73,7 @@ void gr_scheduler_thread::stop() { if (GR_SCHEDULER_THREAD_DEBUG) - std::cout << "gr_scheduler_thread::stop()" << std::endl; + std::cout << "gr_scheduler_thread::stop() " + << this << std::endl; d_sts->stop(); } diff --git a/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc b/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc index 6aaaf954..b2fbdb73 100644 --- a/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc +++ b/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc @@ -82,10 +82,18 @@ gr_single_threaded_scheduler::~gr_single_threaded_scheduler () void gr_single_threaded_scheduler::run () { - d_enabled = true; + // d_enabled = true; // KLUDGE main_loop (); } +void +gr_single_threaded_scheduler::stop () +{ + if (0) + std::cout << "gr_singled_threaded_scheduler::stop() " + << this << std::endl; + d_enabled = false; +} inline static unsigned int round_up (unsigned int n, unsigned int multiple) diff --git a/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h b/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h index 139e50b1..060d3017 100644 --- a/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h +++ b/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h @@ -40,7 +40,7 @@ class gr_single_threaded_scheduler { ~gr_single_threaded_scheduler (); void run (); - void stop () { d_enabled = false; } + void stop (); private: const std::vector d_blocks; diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc b/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc index f0b67ddd..67965407 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc +++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc @@ -167,7 +167,7 @@ void gr_top_block_impl::unlock() { omni_mutex_lock lock(d_reconf); - if (d_lock_count == 0) + if (d_lock_count <= 0) throw std::runtime_error("unpaired unlock() call"); d_lock_count--; diff --git a/gnuradio-core/src/lib/runtime/qa_gr_top_block.cc b/gnuradio-core/src/lib/runtime/qa_gr_top_block.cc index 3322b6ac..52677f0d 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_top_block.cc +++ b/gnuradio-core/src/lib/runtime/qa_gr_top_block.cc @@ -29,9 +29,14 @@ #include #include #include +#include + +#define VERBOSE 0 void qa_gr_top_block::t0() { + if (VERBOSE) std::cout << "qa_gr_top_block::t0()\n"; + gr_top_block_sptr tb = gr_make_top_block("top"); CPPUNIT_ASSERT(tb); @@ -39,10 +44,12 @@ void qa_gr_top_block::t0() void qa_gr_top_block::t1_run() { + if (VERBOSE) std::cout << "qa_gr_top_block::t1()\n"; + gr_top_block_sptr tb = gr_make_top_block("top"); gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 1); + gr_block_sptr head = gr_make_head(sizeof(int), 100000); gr_block_sptr dst = gr_make_null_sink(sizeof(int)); tb->connect(src, 0, head, 0); @@ -52,10 +59,12 @@ void qa_gr_top_block::t1_run() void qa_gr_top_block::t2_start_stop_wait() { + if (VERBOSE) std::cout << "qa_gr_top_block::t2()\n"; + gr_top_block_sptr tb = gr_make_top_block("top"); gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 1000000); + gr_block_sptr head = gr_make_head(sizeof(int), 100000); gr_block_sptr dst = gr_make_null_sink(sizeof(int)); tb->connect(src, 0, head, 0); @@ -68,14 +77,14 @@ void qa_gr_top_block::t2_start_stop_wait() void qa_gr_top_block::t3_lock_unlock() { + if (VERBOSE) std::cout << "qa_gr_top_block::t3()\n"; + gr_top_block_sptr tb = gr_make_top_block("top"); gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 1000000); gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); + tb->connect(src, 0, dst, 0); tb->start(); @@ -88,10 +97,12 @@ void qa_gr_top_block::t3_lock_unlock() void qa_gr_top_block::t4_reconfigure() { + if (VERBOSE) std::cout << "qa_gr_top_block::t4()\n"; + gr_top_block_sptr tb = gr_make_top_block("top"); gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 1); + gr_block_sptr head = gr_make_head(sizeof(int), 100000); gr_block_sptr dst = gr_make_null_sink(sizeof(int)); // Start infinite flowgraph diff --git a/gnuradio-core/src/lib/runtime/qa_gr_top_block.h b/gnuradio-core/src/lib/runtime/qa_gr_top_block.h index 9a243452..278b5ffb 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_top_block.h +++ b/gnuradio-core/src/lib/runtime/qa_gr_top_block.h @@ -35,7 +35,7 @@ class qa_gr_top_block : public CppUnit::TestCase CPPUNIT_TEST(t1_run); CPPUNIT_TEST(t2_start_stop_wait); CPPUNIT_TEST(t3_lock_unlock); - // CPPUNIT_TEST(t4_reconfigure); triggers 'join never returns' bug + CPPUNIT_TEST(t4_reconfigure); // triggers 'join never returns' bug CPPUNIT_TEST_SUITE_END(); -- 2.47.2