home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / semaphores / src / attemptsemaphoreshared.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  1.6 KB  |  77 lines

  1. /*
  2.     $Id$
  3.     $Log$
  4.     Desc:
  5.     Lang: english
  6. */
  7. #include "exec_intern.h"
  8. #include "semaphores.h"
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13.     #include <exec/semaphores.h>
  14.     #include <clib/exec_protos.h>
  15.  
  16.     __AROS_LH1(ULONG, AttemptSemaphoreShared,
  17.  
  18. /*  SYNOPSIS */
  19.     __AROS_LA(struct SignalSemaphore *, sigSem, A0),
  20.  
  21. /*  LOCATION */
  22.     struct ExecBase *, SysBase, 120, Exec)
  23.  
  24. /*  FUNCTION
  25.     Tries to get a shared lock on a signal semaphore. If the lock cannot
  26.     be obtained false is returned. There may be more than one shared lock
  27.     at a time but an exclusive lock prevents all other locks. The lock
  28.     must be released with ReleaseSemaphore().
  29.  
  30.     INPUTS
  31.     sigSem - pointer to semaphore structure
  32.  
  33.     RESULT
  34.     True if the semaphore could be obtained, false otherwise.
  35.  
  36.     NOTES
  37.  
  38.     EXAMPLE
  39.  
  40.     BUGS
  41.  
  42.     SEE ALSO
  43.     ReleaseSemaphore()
  44.  
  45.     INTERNALS
  46.  
  47.     HISTORY
  48.     29-10-95    digulla automatically created from
  49.                 exec_lib.fd and clib/exec_protos.h
  50.  
  51. *****************************************************************************/
  52. {
  53.     __AROS_FUNC_INIT
  54.     __AROS_BASE_EXT_DECL(struct ExecBase *,SysBase)
  55.     ULONG ret=0;
  56.  
  57.     /* Arbitrate for the semaphore structure */
  58.     Forbid();
  59.  
  60.     /*
  61.     If the semaphore is free, shared locked or owned by the current task
  62.     it's possible to get another lock.
  63.     */
  64.     if(sigSem->ss_NestCount<=0||sigSem->ss_Owner==SysBase->ThisTask)
  65.     {
  66.     /* Get it and return success */
  67.     ObtainSemaphoreShared(sigSem);
  68.     ret=1;
  69.     }
  70.  
  71.     /* All done. */
  72.     Permit();
  73.     return ret;
  74.     __AROS_FUNC_EXIT
  75. } /* AttemptSemaphoreShared */
  76.  
  77.