aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2013-04-12 13:41:23 -0700
committerJosh Blum <josh@joshknows.com>2013-04-12 13:41:23 -0700
commitcb2473917665903ee5756aba88daf8d59f8ba137 (patch)
tree38a2bb2ff7922d13964747350b29aabf3d6944d2 /host/lib
parentf01d1a28e2adec61828793c59e3f83817b7f1882 (diff)
parentf1108bd25a369a83ef8227c7564e812d4e27f369 (diff)
downloaduhd-cb2473917665903ee5756aba88daf8d59f8ba137.tar.gz
uhd-cb2473917665903ee5756aba88daf8d59f8ba137.tar.bz2
uhd-cb2473917665903ee5756aba88daf8d59f8ba137.zip
Merge branch 'maint'
Conflicts: host/tests/time_spec_test.cpp
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/transport/super_recv_packet_handler.hpp14
-rw-r--r--host/lib/transport/super_send_packet_handler.hpp14
-rw-r--r--host/lib/types/time_spec.cpp14
3 files changed, 20 insertions, 22 deletions
diff --git a/host/lib/transport/super_recv_packet_handler.hpp b/host/lib/transport/super_recv_packet_handler.hpp
index 7a1972690..5a75d5f0d 100644
--- a/host/lib/transport/super_recv_packet_handler.hpp
+++ b/host/lib/transport/super_recv_packet_handler.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2011-2012 Ettus Research LLC
+// Copyright 2011-2013 Ettus Research LLC
//
// 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
@@ -79,8 +79,7 @@ public:
}
~recv_packet_handler(void){
- _task_barrier_entry.interrupt();
- _task_barrier_exit.interrupt();
+ _task_barrier.interrupt();
_task_handlers.clear();
}
@@ -91,8 +90,7 @@ public:
_props.resize(size);
//re-initialize all buffers infos by re-creating the vector
_buffers_infos = std::vector<buffers_info_type>(4, buffers_info_type(size));
- _task_barrier_entry.resize(size);
- _task_barrier_exit.resize(size);
+ _task_barrier.resize(size);
_task_handlers.resize(size);
for (size_t i = 1/*skip 0*/; i < size; i++){
_task_handlers[i] = task::make(boost::bind(&recv_packet_handler::converter_thread_task, this, i));
@@ -561,7 +559,7 @@ private:
******************************************************************/
UHD_INLINE void converter_thread_task(const size_t index)
{
- _task_barrier_entry.wait();
+ _task_barrier.wait();
//shortcut references to local data structures
buffers_info_type &buff_info = get_curr_buffer_info();
@@ -587,11 +585,11 @@ private:
info.buff.reset(); //effectively a release
}
- _task_barrier_exit.wait();
+ if (index == 0) _task_barrier.wait_others();
}
//! Shared variables for the worker threads
- reusable_barrier _task_barrier_entry, _task_barrier_exit;
+ reusable_barrier _task_barrier;
std::vector<task::sptr> _task_handlers;
size_t _convert_nsamps;
const rx_streamer::buffs_type *_convert_buffs;
diff --git a/host/lib/transport/super_send_packet_handler.hpp b/host/lib/transport/super_send_packet_handler.hpp
index 74e893e67..726742327 100644
--- a/host/lib/transport/super_send_packet_handler.hpp
+++ b/host/lib/transport/super_send_packet_handler.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2011-2012 Ettus Research LLC
+// Copyright 2011-2013 Ettus Research LLC
//
// 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
@@ -61,8 +61,7 @@ public:
}
~send_packet_handler(void){
- _task_barrier_entry.interrupt();
- _task_barrier_exit.interrupt();
+ _task_barrier.interrupt();
_task_handlers.clear();
}
@@ -73,8 +72,7 @@ public:
_props.resize(size);
static const boost::uint64_t zero = 0;
_zero_buffs.resize(size, &zero);
- _task_barrier_entry.resize(size);
- _task_barrier_exit.resize(size);
+ _task_barrier.resize(size);
_task_handlers.resize(size);
for (size_t i = 1/*skip 0*/; i < size; i++){
_task_handlers[i] = task::make(boost::bind(&send_packet_handler::converter_thread_task, this, i));
@@ -272,7 +270,7 @@ private:
******************************************************************/
UHD_INLINE void converter_thread_task(const size_t index)
{
- _task_barrier_entry.wait();
+ _task_barrier.wait();
//shortcut references to local data structures
managed_send_buffer::sptr &buff = _props[index].buff;
@@ -302,11 +300,11 @@ private:
buff->commit(num_vita_words32*sizeof(boost::uint32_t));
buff.reset(); //effectively a release
- _task_barrier_exit.wait();
+ if (index == 0) _task_barrier.wait_others();
}
//! Shared variables for the worker threads
- reusable_barrier _task_barrier_entry, _task_barrier_exit;
+ reusable_barrier _task_barrier;
std::vector<task::sptr> _task_handlers;
size_t _convert_nsamps;
const tx_streamer::buffs_type *_convert_buffs;
diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp
index ec939e52e..2fce841be 100644
--- a/host/lib/types/time_spec.cpp
+++ b/host/lib/types/time_spec.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2011-2012 Ettus Research LLC
+// Copyright 2011-2013 Ettus Research LLC
//
// 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
@@ -16,7 +16,6 @@
//
#include <uhd/types/time_spec.hpp>
-#include <inttypes.h> //imaxdiv, intmax_t
using namespace uhd;
@@ -101,8 +100,9 @@ time_spec_t::time_spec_t(time_t full_secs, long tick_count, double tick_rate){
}
time_spec_t time_spec_t::from_ticks(long long ticks, double tick_rate){
- const imaxdiv_t divres = imaxdiv(ticks, fast_llround(tick_rate));
- return time_spec_t(time_t(divres.quot), double(divres.rem)/tick_rate);
+ const time_t secs_full = time_t(ticks/tick_rate);
+ const double ticks_error = ticks - (secs_full*tick_rate);
+ return time_spec_t(secs_full, ticks_error/tick_rate);
}
/***********************************************************************
@@ -113,8 +113,10 @@ long time_spec_t::get_tick_count(double tick_rate) const{
}
long long time_spec_t::to_ticks(double tick_rate) const{
- return fast_llround(this->get_frac_secs()*tick_rate) + \
- (this->get_full_secs() * fast_llround(tick_rate));
+ const long long ticks_full = this->get_full_secs()*fast_llround(tick_rate);
+ const double secs_error = this->get_full_secs() - (ticks_full/tick_rate);
+ const double secs_frac = this->get_frac_secs() + secs_error;
+ return ticks_full + fast_llround(secs_frac*tick_rate);
}
double time_spec_t::get_real_secs(void) const{