<div dir="ltr">Thank you Miller for your answer.<div><br></div><div>This afternoon I just took a look of s_audio_paring.c/h. </div><div>Do you think the lock in the scheduler can be a problem? It's meaningful a lock free queue between audio and worker thread?</div><div><br></div><div>Best,</div><div>Marco</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-08-23 18:13 GMT+02:00 Miller Puckette <span dir="ltr"><<a href="mailto:msp@ucsd.edu" target="_blank">msp@ucsd.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There's a good, byte-stream lock-free fifo in pd/src/s_audio_paring.c .<br>
(It's borrowed from portaudio).  The difficulty there would be the necessity<br>
of encoding everything into byte streams.  Perhaps just sprintf/sscanf will<br>
do it for you.<br>
<br>
cheers<br>
Miller<br>
<div><div class="h5"><br>
On Tue, Aug 23, 2016 at 03:49:20PM +0200, Marco Matteo Markidis wrote:<br>
> Dear all,<br>
><br>
> I'm developing an external that has two threads, one audio thread and one<br>
> worker thread. The audio thread contains all usual stuff; while the worker<br>
> thread computes calculations (I need knn searches and so on for my<br>
> resynthesis) and put them in a data structure. At the end of calculations,<br>
> the worker thread atomically CAS the data structure.<br>
> Actually, I'm using a [readsf~]-like mechanics with pthread signal to<br>
> communicate between threads.<br>
><br>
> I would like to remove lock and use a lock free system. I don't know if it<br>
> feasible. Moreover I don't know if it has some sense, because Pd locks a<br>
> mutex in scheduler and I don't know if a lock free implementation could be<br>
> a right solution.<br>
><br>
> In the case it could be a solution, I will start with a SPSC circular queue<br>
> and I will use atomic CAS to swap the data structure.<br>
><br>
> Best regards,<br>
><br>
> Marco<br>
<br>
</div></div>> ______________________________<wbr>_________________<br>
> <a href="mailto:Pd-list@lists.iem.at">Pd-list@lists.iem.at</a> mailing list<br>
> UNSUBSCRIBE and account-management -> <a href="https://lists.puredata.info/listinfo/pd-list" rel="noreferrer" target="_blank">https://lists.puredata.info/<wbr>listinfo/pd-list</a><br>
<br>
</blockquote></div><br></div>