[libdispatch-dev] bad instruction while using semaphore (Mac OS X 10.6.3)

Jean-Daniel Dupas devlists at shadowlab.org
Tue Apr 27 12:31:47 PDT 2010


OK, the libdispatch source are clear about this.
But it may be worth documenting the fact that a semaphore MUST NOT be released if the actual count is less then the creation time count ?

Le 27 avr. 2010 à 21:23, Jean-Daniel Dupas a écrit :

> Can someone explain me why I got a "Illegal Instruction" exception when executing the following code (whatever the arch is).
> I'm trying to update code based on mach semaphore, and this is one of my unit test (which works fine with mach semaphore).
> 
> -----------------------------------
> 
> #include <dispatch/dispatch.h>
> 
> int main(int argc, char **argv) {
> 	dispatch_semaphore_t ds = dispatch_semaphore_create(1);
> 	dispatch_semaphore_wait(ds, DISPATCH_TIME_NOW); // count is 0
> 	dispatch_semaphore_wait(ds, DISPATCH_TIME_NOW); // timeout
> 	dispatch_semaphore_signal(ds); // count is 1
> 	dispatch_semaphore_wait(ds, DISPATCH_TIME_NOW); // count is 0
> 	dispatch_release(ds); // crash
> 	return 0;
> }
> 
> -----------------------------------
> 
> Thanks
> -- Jean-Daniel
> 
> 
> 
> 
> _______________________________________________
> libdispatch-dev mailing list
> libdispatch-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev

-- Jean-Daniel




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/libdispatch-dev/attachments/20100427/a5a54d51/attachment.html>


More information about the libdispatch-dev mailing list