[PD-dev] Is gensym() threadsafe?

Kjetil S. Matheussen kjetil at ccrma.stanford.edu
Tue Dec 13 22:58:52 CET 2005


On Tue, 13 Dec 2005, Kjetil S. Matheussen wrote:

> On Tue, 13 Dec 2005, Tim Blechmann wrote:
>
>> hi kjetil,
>> 
>>> I'm working on the snd external, and wonder about gensyms thread
>>> safety. It looks to be, but I'm not quite sure. In case it isn't
>>> is there a locking-mechanism or something I can use?
>>> 
>>> I also see that there are some functions called sys_lock or
>>> something, how does they work?
>> 
>> gensym is basically not thread safe ... for the devel branch i made
>> gensym threadsafe, but if you want to write code for miller's pd, you
>> need to use the syslock ...
>> 
>
> Thanks! So how do I use syslock from another thread?
>
> Does this make sence:?
>
> t_symbol *thread_safe_gensym(char *symbol){
> t_symbol *ret;
> sys_lock();
> ret=gensym(symbol);
> sys_unlock();
> return ret;
> }
>

Hm, no, actually, I can't do that. Snd isn't running with 
realtime priority, so if pd needs to wait for snd, pd will in practice 
lose its realtime priority when it has to wait for Snd.
Miller P.: Please apply Tim's threadsafe gensym to your version. :-)


-- 




More information about the Pd-dev mailing list