Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem while using named semaphores



I think that what you need to do is sem_unlink. That removes the name. The semaphore itself will be deleted when the last reference to it is closed. This is like unlinking a regular file.

Regards.....Peter

On Mar 8, 2004, at 12:15 AM, mukesh bafna wrote:

Hi,
I found sem_init(...) & sem_destroy...) are not
currently supported by mac os x so i am using named
semaphores as a alternative.
But i am having problem to write equivalent of
following code segment using sem_close -

while ( EBUSY == sem_destroy(&semid) )
{
pthread_yield();
}

here we can't merely replace sem_close for sem_destroy
because sem_destroy returns EBUSY when it finds some
thread has called sem_wait for it & is in blocked
state.
whereas when sem_close is called it succeeds unless
sem is not a valid semaphore descriptor.
so here i can't put sem_close call pending till all
the threads come out of sem_wait.

How can i achive this using sem_close or if there
is another alternative to achive this ?

OS -
Darwin macg5.local. 6.8.5 Darwin Kernel Version 6.8.5:
Wed Sep 10 16:22:08 PDT 2003;
root:xnu/xnu-344.21.74.obj~1/RELEASE_PPC Power
Macintosh powerpc

GCC version -
gcc version 3.3 20030304 (Apple Computer, Inc. build
1493)


Thanks,
Mukesh.

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what youre looking for faster
http://search.yahoo.com
_______________________________________________
darwin-userlevel mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-userlevel
Do not post admin requests to the list. They will be ignored.
_______________________________________________
darwin-userlevel mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-userlevel
Do not post admin requests to the list. They will be ignored.


References: 
 >Problem while using named semaphores (From: mukesh bafna <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.