From b107b4604cedd1ea91b45392c979d179a15d5738 Mon Sep 17 00:00:00 2001 From: Paul David Date: Thu, 2 Feb 2017 14:49:53 -0500 Subject: X3xx: Limit the number of USRPs that can initialize in parallel --- host/lib/usrp/x300/x300_impl.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'host/lib/usrp/x300/x300_impl.cpp') diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 116e1e6eb..13d1d6adc 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -430,15 +430,23 @@ x300_impl::x300_impl(const uhd::device_addr_t &dev_addr) uhd::msg::handler_t current_handler = uhd::msg::get_handler(); uhd::msg::register_handler(&thread_msg_handler); - // Thread the initialization process - boost::thread_group setup_threads; - for (size_t i = 0; i < device_args.size(); i++) + // Initialize groups of USRPs in parallel + size_t total_usrps = device_args.size(); + size_t num_usrps = 0; + while (num_usrps < total_usrps) { - setup_threads.create_thread( - boost::bind(&x300_impl::setup_mb, this, i, device_args[i]) - ); + size_t init_usrps = std::min(total_usrps - num_usrps, X300_MAX_INIT_THREADS); + boost::thread_group setup_threads; + for (size_t i = 0; i < init_usrps; i++) + { + size_t index = num_usrps + i; + setup_threads.create_thread( + boost::bind(&x300_impl::setup_mb, this, index, device_args[index]) + ); + } + setup_threads.join_all(); + num_usrps += init_usrps; } - setup_threads.join_all(); // restore the original message handler UHD_MSG(status) << thread_final_msg; -- cgit v1.2.3