summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/vmcircbuf.cc
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-06-14 18:15:50 -0400
committerTom Rondeau <trondeau@vt.edu>2013-06-14 18:15:50 -0400
commit234b0f02a954928c54485c38ef37126ba5197597 (patch)
treef5e8050e9463d80e81e48addb9da873a3c3a20dd /gnuradio-runtime/lib/vmcircbuf.cc
parent2fb6d0a21a133207e9b93545c4fe3754d22cdfc7 (diff)
runtime: 2 threading issues with the shared memory system.
1. Making a global mutex for the VM circular buffers to use and lock for multiple top_blocks to handle accessing the memory. 2. Catch the bad_alloc exception once and retry. After 1., this rarely happens unless the thread count gets large (> 20 as an estimate).
Diffstat (limited to 'gnuradio-runtime/lib/vmcircbuf.cc')
-rw-r--r--gnuradio-runtime/lib/vmcircbuf.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/gnuradio-runtime/lib/vmcircbuf.cc b/gnuradio-runtime/lib/vmcircbuf.cc
index 0fccb3d914..e4e1590205 100644
--- a/gnuradio-runtime/lib/vmcircbuf.cc
+++ b/gnuradio-runtime/lib/vmcircbuf.cc
@@ -40,6 +40,8 @@
#include "vmcircbuf_mmap_shm_open.h"
#include "vmcircbuf_mmap_tmpfile.h"
+gr::thread::mutex s_vm_mutex;
+
namespace gr {
static const char *FACTORY_PREF_KEY = "vmcircbuf_default_factory";
@@ -64,6 +66,8 @@ namespace gr {
bool verbose = false;
+ gr::thread::scoped_lock guard(s_vm_mutex);
+
std::vector<gr::vmcircbuf_factory *> all = all_factories ();
const char *name = gr::vmcircbuf_prefs::get(FACTORY_PREF_KEY);
@@ -288,6 +292,8 @@ namespace gr {
{
bool ok = false;
+ gr::thread::scoped_lock guard(s_vm_mutex);
+
std::vector<vmcircbuf_factory *> all = all_factories();
for(unsigned int i = 0; i < all.size (); i++)