/************************************************************************/
/* Copyright 2002 MBARI							*/
/************************************************************************/
/* Summary  : Definitions for Semaphore library for OASIS3		*/
/* Filename : sem.h							*/
/* Author   : Robert Herlien (rah)					*/
/* Project  : OASIS Mooring Replacement (OASIS3)			*/
/* Revision: 0.1							*/
/* Created  : 10/14/2002						*/
/*									    */
/* MBARI provides this documentation and code "as is", with no warranty,    */
/* express or implied, of its quality or consistency. It is provided without*/
/* support and without obligation on the part of the Monterey Bay Aquarium  */
/* Research Institute to assist in its use, correction, modification, or    */
/* enhancement. This information should not be published or distributed to  */
/* third parties without specific written permission from MBARI.            */
/*									    */
/************************************************************************/
/* Modification History:						*/
/* 10oct2002 rah - created from OASIS sem.h				*/
/************************************************************************/

#ifndef INCsemLibh
#define INCsemLibh	1

typedef Semaphore 	*SemID;		/* Semaphore ID			    */
#define NULLSEM		((SemID)0)

typedef enum				/************************************/
{					/* Type of Semaphore		    */
    MUTEX,				/* Mutual exclusion (returned at exit)*/
    COUNTING				/* Counting			    */
}SemType;				/************************************/
    
typedef struct semaphore		/************************************/
{					/* Semaphore STRUCTURE		    */
    LstHead	sem_list;		/* Linked list of waiting tasks	    */
    SemType	sem_type;		/* Type of semaphore		    */
    Int16	sem_cnt;		/* Semaphore count		    */
};					/************************************/


/****************************************/
/* Function Declarations		*/
/****************************************/

Void	 sem_init( SemID sem, SemType semtype, Int16 count );
Void	 sem_take( Reg SemID sem );
Void	 sem_give( Reg SemID sem );

#endif	/* INCtaskLibh */
