[Insight-developers] Mac Semaphores (Was: Failing tests and compile errors after your check in)

Daniel Blezek Blezek.Daniel at mayo.edu
Fri Feb 18 13:45:48 EST 2011


Hi Brad,

  I suppose the naming convention is wrong.  Should we go with
itkSemaphorePOSIX.cxx?  The semaphores could be implemented with condition
variables.

-dan


On 2/18/11 12:36 PM, "Bradley Lowekamp" <blowekamp at mail.nih.gov> wrote:

> Hello Dan,
> 
> I began looking to this issue as well. You as you indicated there are no
> pthread semaphores, only POSIX semaphores. So the file should be renamed.
> Additionally, you removed a lot of platform specific code for these threading
> related code, the more I am looking at it the more uncomfortable I am becoming
> because of how little tested these classes are.
> 
> Additionally, these POSIX semaphores appear to be designed for interprocess
> communication and not inter-thread. So this is less then ideal.
> 
> We are only using the semaphore class in
> ParallelSparseFieldLevelSetImageFilter and the window implementation for the
> conditionally variable. I am going to look if there is an  easy alternative to
> these uses. If there is a better approach, I am going to propose that this
> class be deprecated and moved to a depricated module in it's original form.
> 
> Brad
> 
> On Feb 18, 2011, at 12:59 PM, Daniel Blezek wrote:
> 
>> POSIX semaphores are not fully supported on the Mac.  I don't know why this
>> works in the 64-bit version...
>> 
>> We are using sem_destroy to destroy our semaphores.  On the 32-bit Mac, I
>> get this return value (perror()):
>> 
>> 536: sem_destroy: Function not implemented
>> 
>> Why this linked and run, I'll never know...  Looks like I need to add some
>> APPLE specific code.  I suspect this will fix the problem on the Sun.
>> 
>> We also have a race-condition in our Semaphore code.  On the Mac, the
>> semaphores need unique names.  We generate this using the time() function,
>> but it has a one second resolution.  Thus if two semaphores are created
>> within 1 second, they will collide.  Not very nice.
>> 
>> I'll try to track this down once again.
>> -dan
>> 
>> 
>> On 2/17/11 11:07 AM, "Bill Lorensen" <bill.lorensen at gmail.com> wrote:
>> 
>>> Dan,
>>> 
>>> I assume you noticed the failing tests and build errors after your
>>> check in yesterday?
>>> 
>>> Bill

-- 
Daniel Blezek, PhD
Medical Imaging Informatics Innovation Center

P 127 or (77) 8 8886
T 507 538 8886
E blezek.daniel at mayo.edu

Mayo Clinic
200 First St. S.W.
Harwick SL-44
Rochester, MN 55905
mayoclinic.org
"It is more complicated than you think." -- RFC 1925

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110218/41614171/attachment.htm>


More information about the Insight-developers mailing list