[Contents] [Index] [Help] [Retrace] [Browse <] [Browse >]


   NAME
        AttemptSemaphoreShared -- try to obtain without blocking       (V37)

   SYNOPSIS
        success = AttemptSemaphoreShared(signalSemaphore)
        D0                               A0

        long attemptsemaphoreshared(struct signalsemaphore *);

   FUNCTION
        This call is similar to obtainsemaphoreshared(), except that it
        will not block if the semaphore could not be locked.

   INPUT
       signalSemaphore -- an initialized signal semaphore structure

   RESULT
        success -- TRUE if the semaphore was granted, false if some
            other task already possessed the semaphore in exclusive mode.

   NOTE
        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);
        }

   SEE ALSO
        obtainsemaphore() obtainsemaphoreshared(), releasesemaphore(),
        exec/semaphores.h