semLibP.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:6k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* semLibP.h - private semaphore library header file */
  2. /* Copyright 1984-2001 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01i,17oct01,bwa  Corrected ASM offsets for events. Added SEM_M_SEND_EVENTS
  7.  definition.
  8. 01h,06sep01,bwa  Added VxWorks events support.
  9. 01g,19may97,jpd  made SEM_TYPE_MASK available from assembler files.
  10. 01f,10jul96,dbt  moved declaration of semMGiveForce to semLib.h (SPR #4352).
  11.  Updated copyright.
  12. 01e,10dec93,smb  added instrument class
  13. 01d,22sep92,rrr  added support for c++
  14. 01c,27jul92,jcf  changed semMTakeKern to semMPendQPut.
  15. 01b,19jul92,pme  added external declaration of shared sem show routine.
  16. 01a,04jul92,jcf  created.
  17. */
  18. #ifndef __INCsemLibPh
  19. #define __INCsemLibPh
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #ifndef _ASMLANGUAGE
  24. #include "vxWorks.h"
  25. #include "vwModNum.h"
  26. #include "semLib.h"
  27. #include "qLib.h"
  28. #include "private/classLibP.h"
  29. #include "private/objLibP.h"
  30. #include "private/eventLibP.h"
  31. #if CPU_FAMILY==I960
  32. #pragma align 1 /* tell gcc960 not to optimize alignments */
  33. #endif /* CPU_FAMILY==I960 */
  34. /* semaphore types */
  35. #define MAX_SEM_TYPE 8 /* maximum # of sem classes */
  36. #endif /* !_ASMLANGUAGE */
  37. #define SEM_TYPE_MASK 0x7 /* semaphore class mask */
  38. #ifndef _ASMLANGUAGE
  39. #define SEM_TYPE_BINARY 0x0 /* binary semaphore */
  40. #define SEM_TYPE_MUTEX 0x1 /* mutual exclusion semaphore */
  41. #define SEM_TYPE_COUNTING 0x2 /* counting semaphore */
  42. #define SEM_TYPE_OLD 0x3 /* VxWorks 4.0 semaphore */
  43. typedef struct semaphore /* SEMAPHORE */
  44.     {
  45.     OBJ_CORE objCore; /* 0x00: object management */
  46.     UINT8 semType; /* 0x04: semaphore type */
  47.     UINT8 options; /* 0x05: semaphore options */
  48.     UINT16 recurse; /* 0x06: semaphore recursive take count */
  49.     Q_HEAD qHead; /* 0x08: blocked task queue head */
  50.     union
  51. {
  52. UINT  count; /* 0x18: current state */
  53. struct windTcb *owner; /* 0x18: current state */
  54. } state;
  55.     EVENTS_RSRC events; /* 0x1c: VxWorks events */
  56.     } SEMAPHORE;
  57. #define semCount state.count
  58. #define semOwner state.owner
  59. /*******************************************************************************
  60. *
  61. * SEMC_IS_FREE - check if a counting semaphore is free
  62. *
  63. * RETURNS: TRUE if the semaphore is free, FALSE if not.
  64. *
  65. * BOOL SEMC_IS_FREE (SEM_ID semId)
  66. *
  67. * NOMANUAL
  68. */
  69. #define SEMC_IS_FREE(semId) (semId->semCount > 0)
  70. /*******************************************************************************
  71. *
  72. * SEMBM_IS_FREE - check if a binary or mutex semaphore is free
  73. *
  74. * RETURNS: TRUE if the semaphore is free, FALSE if not.
  75. *
  76. * BOOL SEMBM_IS_FREE (SEM_ID semId)
  77. *
  78. * NOMANUAL
  79. */
  80. #define SEMBM_IS_FREE(semId) (semId->semOwner == NULL)
  81. #if CPU_FAMILY==I960
  82. #pragma align 0 /* turn off alignment requirement */
  83. #endif /* CPU_FAMILY==I960 */
  84. /* variable declarations */
  85. extern OBJ_CLASS semClass; /* semaphore object class */
  86. extern OBJ_CLASS semInstClass; /* semaphore object class */
  87. extern CLASS_ID semClassId; /* semaphore class id */
  88. extern CLASS_ID semInstClassId; /* semaphore class id */
  89. extern FUNCPTR semGiveTbl []; /* semGive() methods */
  90. extern FUNCPTR semTakeTbl []; /* semTake() methods */
  91. extern FUNCPTR semFlushTbl []; /* semFlush() methods */
  92. extern FUNCPTR semGiveDeferTbl []; /* semGiveDefer() methods */
  93. extern FUNCPTR semFlushDeferTbl []; /* semFlushDefer() methods */
  94. extern int semMGiveKernWork; /* semMGiveKern() parameter */
  95. extern FUNCPTR  semSmShowRtn; /* shared semaphore show routine pointer */
  96. extern FUNCPTR  semSmInfoRtn; /* shared semaphore info routine pointer */
  97. /* function declarations */
  98. #if defined(__STDC__) || defined(__cplusplus)
  99. extern STATUS semLibInit (void);
  100. extern STATUS semTerminate (SEM_ID semId);
  101. extern STATUS semDestroy (SEM_ID semId, BOOL dealloc);
  102. extern STATUS semGiveDefer (SEM_ID semId);
  103. extern STATUS semFlushDefer (SEM_ID semId);
  104. extern STATUS semInvalid (SEM_ID semId);
  105. extern STATUS semIntRestrict (SEM_ID semId);
  106. extern STATUS semQInit (SEMAPHORE *pSemaphore, int options);
  107. extern STATUS semQFlush (SEM_ID semId);
  108. extern void semQFlushDefer (SEM_ID semId);
  109. extern STATUS semBInit (SEMAPHORE *pSem,int options,SEM_B_STATE initialState);
  110. extern STATUS semBCoreInit (SEMAPHORE *pSemaphore, int options,
  111.       SEM_B_STATE initialState);
  112. extern STATUS semBGive (SEM_ID semId);
  113. extern STATUS semBTake (SEM_ID semId, int timeout);
  114. extern void semBGiveDefer (SEM_ID semId);
  115. extern STATUS semMInit (SEMAPHORE *pSem, int options);
  116. extern STATUS semMCoreInit (SEMAPHORE *pSemaphore, int options);
  117. extern STATUS semMGive (SEM_ID semId);
  118. extern STATUS semMTake (SEM_ID semId, int timeout);
  119. extern STATUS semMGiveKern (SEM_ID semId);
  120. extern STATUS semMPendQPut (SEM_ID semId, int timeout);
  121. extern STATUS semCInit (SEMAPHORE *pSem,int options,int initialCount);
  122. extern STATUS semCCoreInit (SEMAPHORE *pSemaphore, int options,
  123.       int initialCount);
  124. extern STATUS semCGive (SEM_ID semId);
  125. extern STATUS semCTake (SEM_ID semId, int timeout);
  126. extern void semCGiveDefer (SEM_ID semId);
  127. extern STATUS semOTake (SEM_ID semId);
  128. #else
  129. extern STATUS semLibInit ();
  130. extern STATUS semTerminate ();
  131. extern STATUS semDestroy ();
  132. extern STATUS semGiveDefer ();
  133. extern STATUS semFlushDefer ();
  134. extern STATUS semInvalid ();
  135. extern STATUS semIntRestrict ();
  136. extern STATUS semQInit ();
  137. extern STATUS semQFlush ();
  138. extern void semQFlushDefer ();
  139. extern STATUS semBInit ();
  140. extern STATUS semBCoreInit ();
  141. extern STATUS semBGive ();
  142. extern STATUS semBTake ();
  143. extern void semBGiveDefer ();
  144. extern STATUS semCInit ();
  145. extern STATUS semCCoreInit ();
  146. extern STATUS semCGive ();
  147. extern STATUS semCTake ();
  148. extern void semCGiveDefer ();
  149. extern STATUS semMInit ();
  150. extern STATUS semMCoreInit ();
  151. extern STATUS semMGive ();
  152. extern STATUS semMTake ();
  153. extern STATUS semMGiveKern ();
  154. extern STATUS semMPendQPut ();
  155. extern STATUS semOTake ();
  156. #endif /* __STDC__ */
  157. #else /* _ASMLANGUAGE */
  158. #define SEM_TYPE 0x04 /* offsets into SEMAPHORE */
  159. #define SEM_OPTIONS 0x05
  160. #define SEM_RECURSE 0x06
  161. #define SEM_Q_HEAD 0x08
  162. #define SEM_STATE 0x18
  163. #define SEM_EVENTS 0x1c
  164. #define SEM_EVENTS_REGISTERED 0x1c
  165. #define SEM_EVENTS_TASKID 0x20
  166. #define SEM_EVENTS_OPTIONS 0x24
  167. #define SEM_INST_RTN 0x30
  168. #endif /* _ASMLANGUAGE */
  169. #define SEM_M_Q_GET 0x1 /* semMGiveKernWork() defines */
  170. #define SEM_M_SAFE_Q_FLUSH 0x2
  171. #define SEM_M_PRI_RESORT 0x4
  172. #define SEM_M_SEND_EVENTS 0x8
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176. #endif /* __INCsemLibPh */