]> git.gag.com Git - debian/gnuradio/commitdiff
Kludged around hang in hier_block2. Merged -r6189:6191 from eb/fg
authoreb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Tue, 28 Aug 2007 05:59:31 +0000 (05:59 +0000)
committereb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Tue, 28 Aug 2007 05:59:31 +0000 (05:59 +0000)
into trunk.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@6193 221aa14e-8319-0410-a670-987f0aec2ac5

gnuradio-core/src/lib/runtime/gr_scheduler_thread.cc
gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc
gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h
gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
gnuradio-core/src/lib/runtime/qa_gr_top_block.cc
gnuradio-core/src/lib/runtime/qa_gr_top_block.h

index 9cce5eaec91684b8cd32e55ac2769cfdcf9c5906..16f36ac5639d99e522a735202147c210b94b91f8 100644 (file)
@@ -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();
 }
index 6aaaf954bca9c74a8f699e612a0809b759ed6856..b2fbdb73be7ff01a53675773e8dcdb394c8085d3 100644 (file)
@@ -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)
index 139e50b13f2ffbc95a2bb78c8e27cdff7cf2863f..060d3017d47b427a87c7cb1c74d1d93ae858ea95 100644 (file)
@@ -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<gr_block_sptr>     d_blocks;
index f0b67ddde12a11dedafeba90ae9a46c662a88870..6796540773ff45ceb0a218e049b6c13e3319be21 100644 (file)
@@ -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--;
index 3322b6ac4f034a5c5edc7d545eddedd760ad19b2..52677f0def015a4b7cab72a6a7a533d45b20a769 100644 (file)
 #include <gr_head.h>
 #include <gr_null_source.h>
 #include <gr_null_sink.h>
+#include <iostream>
+
+#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
index 9a243452d9d9cdfc9a6268bca7a09d2b49563f39..278b5ffb4826ad671c44673eea1ffd6eb4e5069e 100644 (file)
@@ -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();