From c5043c6aec21c9acadfb81594e5c7d10709fdba5 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 16 Nov 2010 11:59:23 -0800 Subject: usrp: use a spawn thread to ensure that a pirate is spawned before continuing (fixes lockup issue) --- host/lib/usrp/usrp2/io_impl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index 83b70bddc..4d9528f66 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -73,6 +73,7 @@ struct usrp2_impl::io_impl{ bool recv_pirate_crew_raiding; alignment_buffer_type::sptr recv_pirate_booty; bounded_buffer::sptr async_msg_fifo; + boost::mutex spawn_mutex; }; /*********************************************************************** @@ -89,6 +90,8 @@ void usrp2_impl::io_impl::recv_pirate_loop( recv_pirate_crew_raiding = true; size_t next_packet_seq = 0; + spawn_mutex.unlock(); + while(recv_pirate_crew_raiding){ managed_recv_buffer::sptr buff = zc_if->get_recv_buff(); if (not buff.get()) continue; //ignore timeout/error buffers @@ -162,11 +165,17 @@ void usrp2_impl::io_init(void){ //create a new pirate thread for each zc if (yarr!!) for (size_t i = 0; i < _data_transports.size(); i++){ + //ensure a non-blocking mutex lock + _io_impl->spawn_mutex.unlock(); + _io_impl->spawn_mutex.lock(); + //spawn a new pirate to plunder the recv booty _io_impl->recv_pirate_crew.create_thread(boost::bind( &usrp2_impl::io_impl::recv_pirate_loop, _io_impl.get(), _data_transports.at(i), _mboards.at(i), i )); + //will block here until the thread unlocks + _io_impl->spawn_mutex.lock(); } } -- cgit v1.2.3