[PD] External with separate thread. Do I need to lock?

Simon Wise simonzwise at gmail.com
Thu May 22 08:44:30 CEST 2014


On 22/05/14 02:01, Rafael Vega wrote:
> Hi.
>
> I'm developing an external that starts a separate pthread to poll some
> hardware inputs. When the outputs change, I need to send a message like [34
> 56( to one of two outlets in the external from my thread.

from your previous emails I'd guess you are using a beagle board, I'm not sure 
what they provide as far as hardware interface goes, but on the Raspberries 
there is a library, and several usable APIs, that give access to the hardware 
interrupts from the GPIOs, either in many languages including C, python, bash 
etc so no need for polling, you can just use a call-back in C or even simpler 
start a call-back program in bash and pipe its (filtered) output to pd via pdsend.

I can send some useful references to the Pi stuff if you are interested.

It really is much better to avoid having polling loops and such in the CPU, 
hardware does this much better ... the GPIO drivers in the Pis offer callbacks, 
DMA and such to avoid this ... probably something similar is available on the 
beagleboard, otherwise that's the advantage of using something like an arduino 
... the polling is then done in the arduino and only the relevant details are 
passed on to the main computer.

A big operating system really isn't the right environment for the kind of timing 
required for low-level hardware interfaces.


Simon



More information about the Pd-list mailing list