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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: initsemaphore.c,v 1.8 1997/01/08 04:08:43 ldp Exp $
  4.  
  5.     Desc: Initialize a SignalSemaphore
  6.     Lang: english
  7. */
  8.  
  9. #include "exec_intern.h"
  10. #include <exec/semaphores.h>
  11. #include <proto/exec.h>
  12.  
  13. /*****************************************************************************
  14.  
  15.     NAME */
  16.  
  17.     AROS_LH1I(void, InitSemaphore,
  18.  
  19. /*  SYNOPSIS */
  20.     AROS_LHA(struct SignalSemaphore *, sigSem, A0),
  21.  
  22. /*  LOCATION */
  23.     struct ExecBase *, SysBase, 93, Exec)
  24.  
  25. /*  FUNCTION
  26.     Prepares a semaphore structure for use by the exec semaphore system,
  27.     i.e. this function must be called after allocating the semaphore and
  28.     before using it or the semaphore functions will fail.
  29.  
  30.     INPUTS
  31.     sigSem - Pointer to semaphore structure
  32.  
  33.     RESULT
  34.  
  35.     NOTES
  36.     Semaphores are shared between the tasks that use them and must
  37.     therefore lie in public (or at least shared) memory.
  38.  
  39.     EXAMPLE
  40.  
  41.     BUGS
  42.  
  43.     SEE ALSO
  44.  
  45.     INTERNALS
  46.  
  47.     HISTORY
  48.     29-10-95    digulla automatically created from
  49.                 exec_lib.fd and clib/exec_protos.h
  50.     21-01-96    fleischer implementation
  51.  
  52. *****************************************************************************/
  53. {
  54.     AROS_LIBFUNC_INIT
  55.  
  56.     /* Clear list of wait messages */
  57.     sigSem->ss_WaitQueue.mlh_Head     = (struct MinNode *)&sigSem->ss_WaitQueue.mlh_Tail;
  58.     sigSem->ss_WaitQueue.mlh_Tail     = NULL;
  59.     sigSem->ss_WaitQueue.mlh_TailPred = (struct MinNode *)&sigSem->ss_WaitQueue.mlh_Head;
  60.  
  61.     /* Set type of Semaphore */
  62.     sigSem->ss_Link.ln_Type = NT_SIGNALSEM;
  63.  
  64.     /* Semaphore is currently unused */
  65.     sigSem->ss_NestCount = 0;
  66.  
  67.     /* Semaphore has no owner yet */
  68.     sigSem->ss_Owner = 0;
  69.  
  70.     /* Semaphore has no queue */
  71.     sigSem->ss_QueueCount = -1;
  72.  
  73.     AROS_LIBFUNC_EXIT
  74. } /* InitSemaphore */
  75.  
  76.