Claiming endpoint vs mutex protected access to endpoint #128
-
|
I am writing a driver for the BladerRF Software Defined Radio device. I would personally prefer to avoid any locking. I also believe, that nobody should try to concurrently call any routines on an SDR, because these devices are by default meant to be configured and used in a non concurrent fashion. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The If you were using For a SDR, I would do something like a Stream struct created when you start transmit or receive that contains the Endpoint, or maybe two separate objects for transmit and receive that may be handled on separate threads. You then use those objects to send or receive samples, and cancel the transfers and release the endpoint when streaming stops. Basically that would be passing the exclusive ownership onto the caller, where they could put it in a Sounds like a cool project! BladeRF is not among the several SDRs I own, but let me know if you want me to take a look at anything. |
Beta Was this translation helpful? Give feedback.
The
Endpointhas internal state tracking pending transfers, so I made it take&mutso that if it is single-owner it doesn't have to pay the cost of synchronization. Typically, it would be owned by a single thread or async task, but if you need to share it you can wrap it in aMutex. It is not extremely expensive to create anEndpoint, but not intended to be re-created every time you submit a transfer. The big problem with that pattern would be that dropping anEndpointcancels all of its pending transfers.If you were using
Queueon v0.1 (and you should be for a SDR, to submit multiple transfers to avoid underflow/overflow in gaps between transfers),Queueis effectively now calledEndpoint.