[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 07/148: using boost threads for control and
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 07/148: using boost threads for control and data |
Date: |
Mon, 15 Aug 2016 00:47:19 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
nwest pushed a commit to annotated tag old_usrp_devel_udp
in repository gnuradio.
commit b86ad014b1efad4bb14fd7d6d3fdc6f163ed26b3
Author: Josh Blum <address@hidden>
Date: Fri Oct 30 17:19:08 2009 -0700
using boost threads for control and data
---
usrp2/host/lib/Makefile.am | 8 ++----
usrp2/host/lib/usrp2_impl.cc | 22 +++++++--------
usrp2/host/lib/usrp2_impl.h | 15 +++++-----
usrp2/host/lib/usrp2_thread.cc | 64 ------------------------------------------
usrp2/host/lib/usrp2_thread.h | 47 -------------------------------
5 files changed, 22 insertions(+), 134 deletions(-)
diff --git a/usrp2/host/lib/Makefile.am b/usrp2/host/lib/Makefile.am
index 772cf14..ea28c68 100644
--- a/usrp2/host/lib/Makefile.am
+++ b/usrp2/host/lib/Makefile.am
@@ -45,8 +45,7 @@ libusrp2_la_SOURCES = \
rx_sample_handler.cc \
strtod_si.c \
usrp2.cc \
- usrp2_impl.cc \
- usrp2_thread.cc
+ usrp2_impl.cc
libusrp2_la_LIBADD = \
$(OMNITHREAD_LA) \
@@ -59,9 +58,8 @@ noinst_HEADERS = \
eth_buffer.h \
eth_common.h \
ethernet.h \
- open_usrp2_socket.h \
+ open_usrp2_socket.h \
pktfilter.h \
ring.h \
usrp2_bytesex.h \
- usrp2_impl.h \
- usrp2_thread.h
+ usrp2_impl.h
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index f320b78..1ac877c 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -24,9 +24,10 @@
#include <usrp2/tune_result.h>
#include <usrp2/copiers.h>
#include <gruel/inet.h>
+#include <gruel/realtime.h>
+#include <gruel/sys_pri.h>
#include <usrp2_types.h>
#include "usrp2_impl.h"
-#include "usrp2_thread.h"
#include "eth_buffer.h"
#include "ethernet.h"
#include "pktfilter.h"
@@ -134,8 +135,8 @@ namespace usrp2 {
d_pf_data(0),
d_pf_ctrl(0),
d_interface_name(ifc),
- d_data_thread(0),
d_data_running(false),
+ d_ctrl_running(false),
d_rx_seqno(-1),
d_tx_seqno(0),
d_next_rid(0),
@@ -228,8 +229,10 @@ namespace usrp2 {
usrp2::impl::~impl()
{
+ //thread cleanup
stop_data_thread();
stop_ctrl_thread();
+ //socket cleanup
delete d_pf_data;
delete d_pf_ctrl;
d_eth_data->close();
@@ -363,14 +366,14 @@ namespace usrp2 {
void
usrp2::impl::start_ctrl_thread()
{
- d_ctrl_tg.create_thread(boost::bind(&usrp2::impl::run_ctrl_thread, this));
+ d_ctrl_thread = new
boost::thread(boost::bind(&usrp2::impl::run_ctrl_thread, this));
}
void
usrp2::impl::stop_ctrl_thread()
{
d_ctrl_running = false;
- d_ctrl_tg.join_all();
+ d_ctrl_thread->join();
}
void
@@ -391,8 +394,7 @@ namespace usrp2 {
void
usrp2::impl::start_data_thread(){
- d_data_thread = new usrp2_thread(this);
- d_data_thread->start();
+ d_data_thread = new
boost::thread(boost::bind(&usrp2::impl::run_data_thread, this));
}
void
@@ -400,16 +402,14 @@ namespace usrp2 {
{
d_data_running = false;
d_data_pending_cond.signal();
-
- void *dummy_status;
- d_data_thread->join(&dummy_status);
-
- d_data_thread = 0; // thread class deletes itself
+ d_data_thread->join();
}
void
usrp2::impl::run_data_thread()
{
+ if (gruel::enable_realtime_scheduling(gruel::sys_pri::usrp2_backend()) !=
gruel::RT_OK)
+ std::cerr << "usrp2: failed to enable realtime scheduling" << std::endl;
d_data_running = true;
while(d_data_running) {
DEBUG_LOG(":");
diff --git a/usrp2/host/lib/usrp2_impl.h b/usrp2/host/lib/usrp2_impl.h
index 0dba663..6073d82 100644
--- a/usrp2/host/lib/usrp2_impl.h
+++ b/usrp2/host/lib/usrp2_impl.h
@@ -65,8 +65,6 @@ namespace usrp2 {
std::string d_interface_name;
std::string d_addr; // FIXME: use u2_mac_addr_t instead
- usrp2_thread *d_data_thread;
- volatile bool d_data_running; // TODO: multistate if needed
int d_rx_seqno;
int d_tx_seqno;
@@ -108,8 +106,6 @@ namespace usrp2 {
static bool parse_mac_addr(const std::string &s, u2_mac_addr_t *p);
void init_etf_data_hdrs(u2_eth_packet_t *p, const std::string &dst, int
word0_flags, int chan, uint32_t timestamp);
void init_etf_ctrl_hdrs(u2_eth_packet_t *p, const std::string &dst, int
word0_flags, uint32_t timestamp);
- void start_data_thread();
- void stop_data_thread();
void init_config_rx_v2_cmd(op_config_rx_v2_cmd *cmd);
void init_config_tx_v2_cmd(op_config_tx_v2_cmd *cmd);
bool transmit_cmd_and_wait(void *cmd, size_t len, pending_reply *p, double
secs=0.0);
@@ -121,17 +117,22 @@ namespace usrp2 {
bool reset_db();
//control thread stuff
- boost::thread_group d_ctrl_tg;
volatile bool d_ctrl_running;
+ boost::thread *d_ctrl_thread;
void start_ctrl_thread();
void stop_ctrl_thread();
void run_ctrl_thread();
+ //data thread stuff
+ volatile bool d_data_running; // TODO: multistate if needed
+ boost::thread *d_data_thread;
+ void start_data_thread();
+ void stop_data_thread();
+ void run_data_thread();
+
public:
impl(const std::string &ifc, props *p, size_t rx_bufsize);
~impl();
-
- void run_data_thread();
std::string mac_addr() const { return d_addr; } // FIXME: convert from
u2_mac_addr_t
std::string interface_name() const { return d_interface_name; }
diff --git a/usrp2/host/lib/usrp2_thread.cc b/usrp2/host/lib/usrp2_thread.cc
deleted file mode 100644
index ab0982d..0000000
--- a/usrp2/host/lib/usrp2_thread.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "usrp2_thread.h"
-#include "usrp2_impl.h"
-#include <gruel/realtime.h>
-#include <gruel/sys_pri.h>
-#include <iostream>
-
-#define USRP2_THREAD_DEBUG 1
-
-namespace usrp2 {
-
- usrp2_thread::usrp2_thread(usrp2::impl *u2) :
- omni_thread(NULL, PRIORITY_HIGH),
- d_u2(u2)
- {
- }
-
- usrp2_thread::~usrp2_thread()
- {
- // we don't own this, just forget it
- d_u2 = 0;
- }
-
- void
- usrp2_thread::start()
- {
- start_undetached();
- }
-
- void *
- usrp2_thread::run_undetached(void *arg)
- {
- if (gruel::enable_realtime_scheduling(gruel::sys_pri::usrp2_backend()) !=
gruel::RT_OK)
- std::cerr << "usrp2: failed to enable realtime scheduling" << std::endl;
-
- // This is the first code to run in the new thread context.
- d_u2->run_data_thread();
-
- return 0;
- }
-
-} // namespace usrp2
-
diff --git a/usrp2/host/lib/usrp2_thread.h b/usrp2/host/lib/usrp2_thread.h
deleted file mode 100644
index 12723e9..0000000
--- a/usrp2/host/lib/usrp2_thread.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_USRP2_THREAD_H
-#define INCLUDED_USRP2_THREAD_H
-
-#include <gnuradio/omnithread.h>
-#include <usrp2_impl.h>
-
-namespace usrp2 {
-
- class usrp2_thread : public omni_thread
- {
- private:
- usrp2::impl *d_u2;
-
- public:
- usrp2_thread(usrp2::impl *u2);
- ~usrp2_thread();
-
- void start();
-
- virtual void *run_undetached(void *arg);
- };
-
-} // namespace usrp2
-
-#endif /* INCLUDED_USRP2_THREAD_H */
- [Commit-gnuradio] [gnuradio] annotated tag old_usrp_devel_udp created (now 90cd6f5), git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 01/148: Create separate raw Ethernet sockets and packet filters, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 03/148: Created a new thread for handling incoming control packets. TX/RX app is working with separate data and control ethernet types., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 10/148: Fix incorrect comparison, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 13/148: usrp2: remove install data hook for usrp2_socket_opener, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 04/148: Hosekeeping after control/data separation., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 05/148: Removed references to U2_ETHERTYPE and CONTROL_CHAN. Moved non-txrx-related apps in firmware broken by this., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 06/148: Common naming convention for control and data thread stuff., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 02/148: working a separate ctrl ethernet device into the code, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 07/148: using boost threads for control and data,
git <=
- [Commit-gnuradio] [gnuradio] 09/148: Refactored timeout handling, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 17/148: Began work on eth data transport class. Switched send in transport to use iovecs. Pass mac addr into eth transports rather than re-parsing., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 14/148: Created transport abstraction. Implemented ethernet transport for control. Control transport works in usrp impl. Needs a lot of cleanup., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 08/148: Removed omnithreads dependency from libusrp2, still debugging, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 18/148: Added a callback into the channel ring enqueue and dequeue. This will allow the deqeue caller to make an arbitrary call when its done with the data. Currently, the enqueue caller makes this callback a release_frames., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 15/148: virtual destructor and shared ptr for transport, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 28/148: Cleaned up the parse ethernet stuff. Made an official max_buffs method for the transport., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 20/148: Created sbuff class to house chunks of memory, their length, and possible callback for freeing/cleanup. Switched ring and transport to make use of the sbuff on receive., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 37/148: Fixes usrp2 firmware configure with mb-gcc on ubuntu 9.10/autoconf 2.64. Disables the regression test for fopen since stdio is non-functional., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 22/148: usrp2 impl working with data transport. not up to full potential yet, but working. needs major cleanup., git, 2016/08/14