Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] An oddity

Date2008-06-04 17:01
FromMichael Gogins
SubjectRe: [Cs-dev] An oddity
I understand what you are saying, but in this context it is better to return the address of a static variable than to change the whole API signature. 

pthread_t can be type cast to void * on all platforms but Windows. All the other Csound threading API calls use void * for various pthread handles. The only pthread handle that is not still a pointer on Windows is pthread_t. The only problem caused by pthread_t not being a pointer is in this one single function; in all other cases the pointer contains an address to the original pthread_t object created on the heap.

I agree that this is a hack, but if it actually causes problems in practice we can keep a map of addresses to pthread_t structures around, or we can come up with some other solution, such as a changing the signature of this one function.

It is NOT a good idea to change the whole threading API signature for this one minor problem. Right now, everything is working and all the original clients of the API are working, and hardly any work needed to be done.

Now that I'm thinking about it, I think it's best to keep a map of pthread_t objects around. Then in this function, we would compare the value of pthread_self to the value of the objects in the map, and return the address of the originally created object. Then the pthread_self stack object would just go away. No harm done.

Regards,
Mike


-----Original Message-----
>From: Fons Adriaensen 
>Sent: Jun 4, 2008 9:24 AM
>To: csound-devel@lists.sourceforge.net
>Subject: Re: [Cs-dev] An oddity
>
>On Wed, Jun 04, 2008 at 08:37:08AM -0400, Michael Gogins wrote:
>
>> I suppose pthread_t pthread could be static pthread_t pthread, but otherwise 
>> please do not change this unless you can come up with a solution that will 
>> work on Windows as well as on the other platforms.
>
>Either way it's broken. The local pthread variable doesn't
>exist anymore when this function returns - whatever the
>return value points to can be overwritten at any time.
>If you make it static the function is no longer re-entrant,
>and clearly in a multi-threading context it has to be.
>
>This is not a solution. The solution is to make whatever code
>that uses pthread_t not to depend on its size.
>
>Ciao,
>
>-- 
>FA
>
>Laboratorio di Acustica ed Elettroacustica
>Parma, Italia
>
>Lascia la spina, cogli la rosa.
>
>
>-------------------------------------------------------------------------
>Check out the new SourceForge.net Marketplace.
>It's the best place to buy or sell services for
>just about anything Open Source.
>http://sourceforge.net/services/buy/index.php
>_______________________________________________
>Csound-devel mailing list
>Csound-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/csound-devel




-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2008-06-04 17:40
FromFons Adriaensen
SubjectRe: [Cs-dev] An oddity
AttachmentsNone