On Monday, December 9, 2002, at 12:23 PM, Valerio Ferrucci wrote:
I use this code:
To create the semaphore
if (semaphoreP = (semaphore_t*)malloc(sizeof(semaphore_t)))
{ bzero(semaphoreP, sizeof(semaphore_t));
err = semaphore_create(mach_task_self(), semaphoreP, SYNC_POLICY_FIFO,
1);
}
A Mach semaphore_t is just a 32bit integer (A Mach port name). It's
kind of overkill to malloc and bzero space for it. Just create it
and pass the name around in the same task. Use Mach messaging to
pass the send right to other tasks.
To wait the semaphore:
err = semaphore_wait(semaphoreP);
(but this returns 15 in err)
If a semaphoreP is a pointer to a semaphore_t, and semaphore_wait()
takes a semaphore_t, you should use:
err = semaphore_wait(*semaphoreP);
--Jim
_______________________________________________
unix-porting mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/unix-porting
Do not post admin requests to the list. They will be ignored.