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

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


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




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


More information about the libdispatch-dev mailing list