aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/common/recv_packet_demuxer_3000.hpp8
-rw-r--r--host/lib/usrp/e300/e300_fifo_config.cpp15
2 files changed, 14 insertions, 9 deletions
diff --git a/host/lib/usrp/common/recv_packet_demuxer_3000.hpp b/host/lib/usrp/common/recv_packet_demuxer_3000.hpp
index a970e81a5..2fe534c03 100644
--- a/host/lib/usrp/common/recv_packet_demuxer_3000.hpp
+++ b/host/lib/usrp/common/recv_packet_demuxer_3000.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2013 Ettus Research LLC
+// Copyright 2013,2017 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
@@ -84,7 +84,7 @@ namespace uhd{ namespace usrp{
//----------------------------------------------------------
//-- Try to claim the transport or wait patiently
//----------------------------------------------------------
- if (_claimed.cas(1, 0))
+ if (_claimed.exchange(true))
{
boost::mutex::scoped_lock l(mutex);
cond.timed_wait(l, boost::posix_time::microseconds(long(timeout*1e6)));
@@ -111,7 +111,7 @@ namespace uhd{ namespace usrp{
}
}
#ifdef RECV_PACKET_DEMUXER_3000_THREAD_SAFE
- _claimed.write(0);
+ _claimed = false;
cond.notify_all();
#endif // RECV_PACKET_DEMUXER_3000_THREAD_SAFE
}
@@ -133,7 +133,7 @@ namespace uhd{ namespace usrp{
std::map<uint32_t, queue_type_t> _queues;
transport::zero_copy_if::sptr _xport;
#ifdef RECV_PACKET_DEMUXER_3000_THREAD_SAFE
- uhd::atomic_uint32_t _claimed;
+ std::atomic_bool _claimed;
boost::condition_variable cond;
#endif // RECV_PACKET_DEMUXER_3000_THREAD_SAFE
boost::mutex mutex;
diff --git a/host/lib/usrp/e300/e300_fifo_config.cpp b/host/lib/usrp/e300/e300_fifo_config.cpp
index 3d0f0d497..556e19120 100644
--- a/host/lib/usrp/e300/e300_fifo_config.cpp
+++ b/host/lib/usrp/e300/e300_fifo_config.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2013-2014 Ettus Research LLC
+// Copyright 2013-2017 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
@@ -17,8 +17,9 @@
#ifdef E300_NATIVE
-#include <stdint.h>
#include <uhd/config.hpp>
+#include <stdint.h>
+#include <atomic>
// constants coded into the fpga parameters
static const size_t ZF_CONFIG_BASE = 0x40000000;
@@ -100,9 +101,13 @@ struct e300_fifo_poll_waiter
//NOP
}
+ /*!
+ * Waits until the file descriptor fd has data to read.
+ * Access to the file descriptor is thread safe.
+ */
void wait(const double timeout)
{
- if (_poll_claimed.cas(1, 0))
+ if (_poll_claimed.exchange(true))
{
boost::mutex::scoped_lock l(mutex);
cond.wait(l);
@@ -116,12 +121,12 @@ struct e300_fifo_poll_waiter
if (fds[0].revents & POLLIN)
::read(fd, NULL, 0);
- _poll_claimed.write(0);
+ _poll_claimed = false;
cond.notify_all();
}
}
- uhd::atomic_uint32_t _poll_claimed;
+ std::atomic_bool _poll_claimed;
boost::condition_variable cond;
boost::mutex mutex;
int fd;