home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / exec / attemptsemaphoreshared.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  2.3 KB  |  97 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: attemptsemaphoreshared.c,v 1.7 1997/01/01 03:46:06 ldp Exp $
  4.     $Log: attemptsemaphoreshared.c,v $
  5.     Revision 1.7  1997/01/01 03:46:06  ldp
  6.     Committed Amiga native (support) code
  7.  
  8.     Changed clib to proto
  9.  
  10.     Revision 1.6  1996/12/10 13:51:39  aros
  11.     Moved all #include's in the first column so makedepend can see it.
  12.  
  13.     Revision 1.5  1996/10/24 15:50:45  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.4  1996/08/13 13:55:58  digulla
  17.     Replaced AROS_LA by AROS_LHA
  18.     Replaced some AROS_LH*I by AROS_LH*
  19.     Sorted and added includes
  20.  
  21.     Revision 1.3  1996/08/01 17:41:05  digulla
  22.     Added standard header for all files
  23.  
  24.     Desc:
  25.     Lang: english
  26. */
  27. #include "exec_intern.h"
  28. #include "semaphores.h"
  29. #include <exec/semaphores.h>
  30. #include <proto/exec.h>
  31.  
  32. /*****************************************************************************
  33.  
  34.     NAME */
  35.  
  36.     AROS_LH1(ULONG, AttemptSemaphoreShared,
  37.  
  38. /*  SYNOPSIS */
  39.     AROS_LHA(struct SignalSemaphore *, sigSem, A0),
  40.  
  41. /*  LOCATION */
  42.     struct ExecBase *, SysBase, 120, Exec)
  43.  
  44. /*  FUNCTION
  45.     Tries to get a shared lock on a signal semaphore. If the lock cannot
  46.     be obtained false is returned. There may be more than one shared lock
  47.     at a time but an exclusive lock prevents all other locks. The lock
  48.     must be released with ReleaseSemaphore().
  49.  
  50.     INPUTS
  51.     sigSem - pointer to semaphore structure
  52.  
  53.     RESULT
  54.     True if the semaphore could be obtained, false otherwise.
  55.  
  56.     NOTES
  57.  
  58.     EXAMPLE
  59.  
  60.     BUGS
  61.  
  62.     SEE ALSO
  63.     ReleaseSemaphore()
  64.  
  65.     INTERNALS
  66.  
  67.     HISTORY
  68.     29-10-95    digulla automatically created from
  69.                 exec_lib.fd and clib/exec_protos.h
  70.  
  71. *****************************************************************************/
  72. {
  73.     AROS_LIBFUNC_INIT
  74.     AROS_LIBBASE_EXT_DECL(struct ExecBase *,SysBase)
  75.     LONG ret=0;
  76.  
  77.     /* Arbitrate for the semaphore structure */
  78.     Forbid();
  79.  
  80.     /*
  81.     If the semaphore is free, shared locked or owned by the current task
  82.     it's possible to get another lock.
  83.     */
  84.     if(sigSem->ss_NestCount<=0||sigSem->ss_Owner==SysBase->ThisTask)
  85.     {
  86.     /* Get it and return success */
  87.     ObtainSemaphoreShared(sigSem);
  88.     ret=1;
  89.     }
  90.  
  91.     /* All done. */
  92.     Permit();
  93.     return ret;
  94.     AROS_LIBFUNC_EXIT
  95. } /* AttemptSemaphoreShared */
  96.  
  97.