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@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev

-- Jean-Daniel