On 09/26/2015 12:22 PM, Coburn wrote:
> Hi Josh
>
> I can probe and find using SoapyRemote without problems now.
>
> Your suggestion of using gdb and you intuition of the problem feeling
> segfaulty allowed me to isolate my problem to the SoapyServerTheadData
> destructor. I wrapped thread->join() and delete thread in a check for
> nullptr. This must be somehow related to the distribution or libraries
> used on the BeagleBone, and may be as easy to fix as adding a compile
> option to the makefile.
>
> I would be very happy explore any thoughts you might have to find why this
> anomaly shows up on bbb.
The TheadDatas are stored in a std::map, I think on some implementations
of the stl, a instance of TheadData is getting default constructed,
assigned, and later destroyed -- without ever getting its thread
initialized, hence the error.
It may not even be a bug. And so TheadData wasn't being very robust in
how it was implemented. This is probably the right fix. Thanks for
finding that, I pushed the fix.
>
> On an entirely different tact, as i develop my hardware function library
> that Soapy calls into, how much of my threading will i be able to rely on
> soapy for. IE, is it conceivable to have a usable library with no thread
> code at all?
>
Most of the hardware libraries and the corresponding Soapy wrappers
don't have any thread code at all. Generally the calling code for
read/writeStream is actually performing the work in terms of dealing
with the buffers and the underlying transport or dma. I have only really
seen threads with libusb based devices -- because thats just how libusb
works.
Some client programs will call into various configuration settings from
multiple threads, so its probably worthwhile to put mutex locks into
either the configuration calls or the spi/i2c code -- or whatever it
takes to make it robust against a multi-thread configuration race condition.
Something else that you might want to look at. There are actually two
stream APIs, the read/writeStream and a direct buffer access API. Quite
a few boards implement the direct buffer access calls, and then make the
read/writeStream just a simple wrapper on top of the direct access.
Just mentioning it because embedded boards are usually a good use case
for this feature -- and client code may want to spare the extra cycles
used to convert or memcpy the buffer and just use it hot and fresh off
the DMA.
Example:
https://github.com/myriadrf/Novena-RF/blob/master/driver/host/Streaming.cpp
-josh