/* ******************* ******************************* C HEADER FILE ******************************* ** ******************* ** ** ** ** project : The C Kernel ** ** filename : CKSEMA.H ** ** version : 2 ** ** last revised : August 22, 2004 ** ** ** ***************************************************************************** ** ** ** Copyright (c) 1998-2004, P.K. van der Vlugt ** ** All rights reserved. ** ** ** ***************************************************************************** Semaphore Resource module. VERSION HISTORY: ---------------- Version : 1 Date : June 01, 2003 Revised by : P.K. van der Vlugt Description : Original version Version : 2 Date : August 22, 2004 Revised by : P.K. van der Vlugt Description : * Changed module name to comply to new kernel module naming convention. */ #ifndef _CKSEMA_INCLUDED #define _CKSEMA_INCLUDED /****************************************************************************/ /** **/ /** MODULES USED **/ /** **/ /****************************************************************************/ #include "ckconfig.h" /****************************************************************************/ /** **/ /** DEFINITIONS AND MACROS **/ /** **/ /****************************************************************************/ /****************************************************************************/ /** **/ /** TYPEDEFS AND STRUCTURES **/ /** **/ /****************************************************************************/ typedef struct { bool req; int16s count; int8u qid; int8u mode; } SemaType; /****************************************************************************/ /** **/ /** EXPORTED VARIABLES **/ /** **/ /****************************************************************************/ #ifndef _CKSEMA_C_SRC #if NR_OF_SEMAS > 0 extern SemaType Sema[NR_OF_SEMAS]; #endif #endif /****************************************************************************/ /** **/ /** EXPORTED FUNCTIONS **/ /** **/ /****************************************************************************/ /****************************************************************************/ void SemaInit (void); /****************************************************************************/ /* * Initializes all resources in this module. This function must be called * before any other functions of this module are used. */ /****************************************************************************/ int8u SemaAlloc (void); /****************************************************************************/ /* * This function requests one of the available resources. If a resource * is available, the resource id will be returned. If there are no more * resources avaliable, NR_OF_SEMAS will be returned to indicate the * error situation. Other errors also return NR_OF_SEMAS. */ /****************************************************************************/ void SemaFree (int8u id); /****************************************************************************/ /* * This function releases the specified resource id when it is a valid id. * The resource is set back to the initial state. The associated resource * (task queue) is also released. */ #endif /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/