Docs » Autodocs » exec.library » AttemptSemaphoreShared
AttemptSemaphoreShared -- try to obtain without blocking (V37)
success = AttemptSemaphoreShared(signalSemaphore) D0 A0 LONG AttemptSemaphoreShared(struct SignalSemaphore *);
This call is similar to ObtainSemaphoreShared(), except that it will not block if the semaphore could not be locked.
signalSemaphore -- an initialized signal semaphore structure
success -- TRUE if the semaphore was granted, false if some other task already possessed the semaphore in exclusive mode.
This call does NOT preserve registers. Starting in V39 this call will grant the semaphore if the caller is already the owner of an exclusive lock on the semaphore. In pre-V39 systems this would not be the case. If you need this feature you can do the following workaround: LONG myAttemptSempahoreShared(struct SignalSemaphore *ss) { LONG result; /* Try for a shared semaphore */ if (!(result=AttemptSemaphoreShared(ss))) { /* Now try for the exclusive one... */ result=AttempSemaphore(ss); } return(result); }
ObtainSemaphore(), ObtainSemaphoreShared(), ReleaseSemaphore(), <exec/semaphores.h>
|