diff options
Diffstat (limited to 'gcell/lib/runtime')
-rw-r--r-- | gcell/lib/runtime/Makefile.am | 4 | ||||
-rw-r--r-- | gcell/lib/runtime/gc_client_thread_info.h | 10 | ||||
-rw-r--r-- | gcell/lib/runtime/gc_job_manager_impl.cc | 45 | ||||
-rw-r--r-- | gcell/lib/runtime/gc_job_manager_impl.h | 10 |
4 files changed, 35 insertions, 34 deletions
diff --git a/gcell/lib/runtime/Makefile.am b/gcell/lib/runtime/Makefile.am index 2c653918e..4d13790cd 100644 --- a/gcell/lib/runtime/Makefile.am +++ b/gcell/lib/runtime/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2007,2008 Free Software Foundation, Inc. +# Copyright 2007,2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ include $(top_srcdir)/Makefile.common IBM_PPU_SYNC_INCLUDES = -I$(top_srcdir)/gcell/ibm/sync/ppu_source -AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) $(MBLOCK_INCLUDES) $(CPPUNIT_INCLUDES) \ +AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) \ $(GCELL_INCLUDES) $(IBM_PPU_SYNC_INCLUDES) $(WITH_INCLUDES) diff --git a/gcell/lib/runtime/gc_client_thread_info.h b/gcell/lib/runtime/gc_client_thread_info.h index 9f46ecca7..e49c07097 100644 --- a/gcell/lib/runtime/gc_client_thread_info.h +++ b/gcell/lib/runtime/gc_client_thread_info.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,7 +21,7 @@ #ifndef INCLUDED_GC_CLIENT_THREAD_INFO_H #define INCLUDED_GC_CLIENT_THREAD_INFO_H -#include <gnuradio/omnithread.h> +#include <boost/thread.hpp> #include <boost/utility.hpp> enum gc_ct_state { @@ -40,7 +40,7 @@ enum gc_ct_state { class gc_client_thread_info : boost::noncopyable { public: gc_client_thread_info() : - d_free(1), d_cond(&d_mutex), d_state(CT_NOT_WAITING), + d_free(1), d_cond(), d_state(CT_NOT_WAITING), d_jobs_done(0), d_njobs_waiting_for(0), d_jobs_waiting_for(0){ } @@ -59,10 +59,10 @@ public: uint16_t d_client_id; //! hold this mutex to manipulate anything below here - omni_mutex d_mutex; + boost::mutex d_mutex; //! signaled by event handler to wake client thread up - omni_condition d_cond; + boost::condition_variable d_cond; //! Is this client waiting? gc_ct_state d_state; diff --git a/gcell/lib/runtime/gc_job_manager_impl.cc b/gcell/lib/runtime/gc_job_manager_impl.cc index cc49fd1f3..58597cf27 100644 --- a/gcell/lib/runtime/gc_job_manager_impl.cc +++ b/gcell/lib/runtime/gc_job_manager_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. + * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -39,6 +39,7 @@ #include <string.h> #include <sched.h> +typedef boost::unique_lock<boost::mutex> scoped_lock; #define __nop() __asm__ volatile ("ori 0,0,0" : : : "memory") #define __cctpl() __asm__ volatile ("or 1,1,1" : : : "memory") @@ -116,9 +117,9 @@ is_power_of_2(uint32_t x) gc_job_manager_impl::gc_job_manager_impl(const gc_jm_options *options) : d_debug(0), d_spu_args(0), - d_eh_cond(&d_eh_mutex), d_eh_thread(0), d_eh_state(EHS_INIT), + d_eh_cond(), d_eh_thread(0), d_eh_state(EHS_INIT), d_shutdown_requested(false), - d_jc_cond(&d_jc_mutex), d_jc_thread(0), d_jc_state(JCS_INIT), d_jc_njobs_active(0), + d_jc_cond(), d_jc_thread(0), d_jc_state(JCS_INIT), d_jc_njobs_active(0), d_ntell(0), d_tell_start(0), d_client_thread(0), d_ea_args_maxsize(0), d_proc_def(0), d_proc_def_ls_addr(0), d_nproc_defs(0) @@ -368,12 +369,12 @@ gc_job_manager_impl::~gc_job_manager_impl() bool gc_job_manager_impl::shutdown() { - omni_mutex_lock l(d_eh_mutex); + scoped_lock l(d_eh_mutex); { - omni_mutex_lock l2(d_jc_mutex); + scoped_lock l2(d_jc_mutex); d_shutdown_requested = true; // set flag for event handler thread - d_jc_cond.signal(); // wake up job completer + d_jc_cond.notify_one(); // wake up job completer } // should only happens during early QA code @@ -381,7 +382,7 @@ gc_job_manager_impl::shutdown() return false; while (d_eh_state != EHS_DEAD) // wait for it to finish - d_eh_cond.wait(); + d_eh_cond.wait(l); return true; } @@ -459,13 +460,13 @@ gc_job_manager_impl::free_job_desc(gc_job_desc *jd) inline bool gc_job_manager_impl::incr_njobs_active() { - omni_mutex_lock l(d_jc_mutex); + scoped_lock l(d_jc_mutex); if (d_shutdown_requested) return false; if (d_jc_njobs_active++ == 0) // signal on 0 to 1 transition - d_jc_cond.signal(); + d_jc_cond.notify_one(); return true; } @@ -473,7 +474,7 @@ gc_job_manager_impl::incr_njobs_active() inline void gc_job_manager_impl::decr_njobs_active(int n) { - omni_mutex_lock l(d_jc_mutex); + scoped_lock l(d_jc_mutex); d_jc_njobs_active -= n; } @@ -614,7 +615,7 @@ gc_job_manager_impl::wait_jobs(unsigned int njobs, } { - omni_mutex_lock l(cti->d_mutex); + scoped_lock l(cti->d_mutex); // setup info for event handler cti->d_state = (mode == GC_WAIT_ANY) ? CT_WAIT_ANY : CT_WAIT_ALL; @@ -646,7 +647,7 @@ gc_job_manager_impl::wait_jobs(unsigned int njobs, // FIXME what happens when somebody calls shutdown? - cti->d_cond.wait(); // wait for event handler to wake us up + cti->d_cond.wait(l); // wait for event handler to wake us up } cti->d_state = CT_NOT_WAITING; @@ -835,17 +836,17 @@ gc_job_manager_impl::create_event_handler() void gc_job_manager_impl::set_eh_state(evt_handler_state s) { - omni_mutex_lock l(d_eh_mutex); + scoped_lock l(d_eh_mutex); d_eh_state = s; - d_eh_cond.broadcast(); + d_eh_cond.notify_all(); } void gc_job_manager_impl::set_ea_args_maxsize(int maxsize) { - omni_mutex_lock l(d_eh_mutex); + scoped_lock l(d_eh_mutex); d_ea_args_maxsize = maxsize; - d_eh_cond.broadcast(); + d_eh_cond.notify_all(); } void @@ -956,7 +957,7 @@ gc_job_manager_impl::notify_clients_jobs_are_done(unsigned int spe_num, // FIXME we could distinguish between CT_WAIT_ALL & CT_WAIT_ANY if (last_cti->d_state == CT_WAIT_ANY || last_cti->d_state == CT_WAIT_ALL) - last_cti->d_cond.signal(); // wake client thread up + last_cti->d_cond.notify_one(); // wake client thread up last_cti->d_mutex.unlock(); cti->d_mutex.lock(); @@ -970,7 +971,7 @@ gc_job_manager_impl::notify_clients_jobs_are_done(unsigned int spe_num, // "wind-out" if (last_cti->d_state == CT_WAIT_ANY || last_cti->d_state == CT_WAIT_ALL) - last_cti->d_cond.signal(); // wake client thread up + last_cti->d_cond.notify_one(); // wake client thread up last_cti->d_mutex.unlock(); ci->in_use = 0; // clear flag so SPE knows we're done with it @@ -1189,13 +1190,13 @@ gc_job_manager_impl::job_completer_loop() while (1){ { - omni_mutex_lock l(d_jc_mutex); + scoped_lock l(d_jc_mutex); if (d_jc_njobs_active == 0){ if (d_shutdown_requested){ d_jc_state = JCS_DEAD; return; } - d_jc_cond.wait(); + d_jc_cond.wait(l); } } @@ -1280,10 +1281,10 @@ gc_job_manager_impl::free_cti(gc_client_thread_info *cti) int gc_job_manager_impl::ea_args_maxsize() { - omni_mutex_lock l(d_eh_mutex); + scoped_lock l(d_eh_mutex); while (d_ea_args_maxsize == 0) // wait for it to be initialized - d_eh_cond.wait(); + d_eh_cond.wait(l); return d_ea_args_maxsize; } diff --git a/gcell/lib/runtime/gc_job_manager_impl.h b/gcell/lib/runtime/gc_job_manager_impl.h index a56117870..640fdfe79 100644 --- a/gcell/lib/runtime/gc_job_manager_impl.h +++ b/gcell/lib/runtime/gc_job_manager_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. + * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -107,16 +107,16 @@ class gc_job_manager_impl : public gc_job_manager boost::shared_ptr<void> _d_comp_info_boost; // hack for automatic storage mgmt // used to coordinate communication w/ the event handling thread - omni_mutex d_eh_mutex; - omni_condition d_eh_cond; + boost::mutex d_eh_mutex; + boost::condition_variable d_eh_cond; pthread_t d_eh_thread; // the event handler thread volatile evt_handler_state d_eh_state; volatile bool d_shutdown_requested; spe_event_handler d_spe_event_handler; // used to coordinate communication w/ the job completer thread - omni_mutex d_jc_mutex; - omni_condition d_jc_cond; + boost::mutex d_jc_mutex; + boost::condition_variable d_jc_cond; pthread_t d_jc_thread; // the job completion thread volatile job_completer_state d_jc_state; int d_jc_njobs_active; // # of jobs submitted but not yet reaped |