<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
My questions are:<br>
<br>
1) Have I completely misunderstood d_soundfile.c and it is actually entirely safe. If so, why is it safe?<br>
<br></blockquote><div><br></div><div>It depends whether the OS implements priority inheritance (<a href="https://en.wikipedia.org/wiki/Priority_inheritance">https://en.wikipedia.org/wiki/Priority_inheritance</a>).</div><div>I think Windows does something like this, not sure, and perhaps Mac OS X too.</div><div>In Linux, you must call pthread_mutexattr_setprotocol(mutex, PTHREAD_PRIO_INHERIT) to</div><div>get priority inheritance for your lock. Alternatively, you can just boost the priority manually before</div><div>obtaining the lock, and unboost after releasing.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
2) Why doesn’t Pd glitch more often when using these objects?<br>
<br></blockquote><div>Probably because the lock is held for so short durations that the OS very seldomly has</div><div>had the chance to interrupt the thread, and for those few times it has happened, no real time</div><div>priority thread had suffered from it, and for those very very very few times where a realtime priority</div><div>thread has suffered, it hadn't suffered enough to cause a glitch.</div><div><br></div></div></div></div>