1 /******************************************************************************
2 ###############################################################################
3 # Copyright (c) [2017-2020] [ICT/CAS] #
4 # Licensed under the ORAN Software License v1.0 (License) #
5 ###############################################################################
6 ******************************************************************************/
17 #endif /* __cplusplus */
20 #define VOS_WAIT_FOREVER -1
23 #define VOS_WAIT_NO_WAIT 0
29 VOS_SEM_EMPTY, ///< 0: semaphore not available
30 VOS_SEM_FULL ///< 1: semaphore available
33 /** 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO */
35 VOS_SEM_Q_FIFO = 0x0, ///< first in first out queue
36 VOS_SEM_Q_PRIORITY = 0x1, ///< priority sorted queue
37 VOS_SEM_DELETE_SAFE = 0x4, ///< owner delete safe (mutex opt.)
38 VOS_SEM_INVERSION_SAFE = 0x8, ///< no priority inversion (mutex opt.)
43 * 创建Bianary类型的信号量,linux中 与Count类型 一致
44 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
45 * @param[in] enInitialState 初始化状态,VOS_SEM_B_STATE 类型的枚举值
46 * @return 返回SEM_ID,失败则返回 0
48 #define VOS_SemBCreate(lOption, enInitialState) __VOS_SemBCreate(lOption, enInitialState, __FUNCTION__, __LINE__)
53 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
54 * @param[in] enInitialState 初始化状态,VOS_SEM_B_STATE 类型的枚举值
55 * @return 返回SEM_ID,失败则返回 0
57 #define VOS_SemCCreate(lOption, enInitialState) __VOS_SemCCreate(lOption, enInitialState, __FUNCTION__, __LINE__)
62 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
63 * @return 返回SEM_ID,失败则返回 0
65 #define VOS_SemMCreate(lOption) __VOS_SemMCreate(lOption, __FUNCTION__, __LINE__)
70 * @param[in] semID 信号量ID
71 * @param[in] lMsec 超时等待的时间,单位毫秒,也可以为VOS_WAIT_FOREVER或VOS_NO_WAIT
72 * @return VOS_OK - 成功,其他 - 失败/超时
74 LONG VOS_SemTake(ULONG semID, LONG lMsec);
79 * @param[in] semID 信号量ID
80 * @return VOS_OK - 成功,其他 - 失败
82 LONG VOS_SemGive(ULONG semID);
87 * @param[in] semID 信号量ID
88 * @return VOS_OK - 成功,其他 - 失败
90 LONG VOS_SemDelete(ULONG semID);
97 /* ###### 下面的函数不要直接调用,使用上面提供的宏 ###### */
101 * 不要直接调用该API,通过宏 VOS_SemBCreate 使用
102 * 创建Bianary类型的信号量,linux中 与Count类型 一致
103 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
104 * @param[in] enInitialState 初始化状态,VOS_SEM_B_STATE 类型
105 * @param[in] pFunc 调用该API的文件名
106 * @param[in] iLine 调用该API的行号
107 * @return 返回SEM_ID,失败则返回 0
109 ULONG __VOS_SemBCreate(LONG lOption, VOS_SEM_B_STATE enInitialState,const CHAR *pFunc, INT iLine);
113 * 不要直接调用该API,通过宏 VOS_SemCCreate 使用
114 * 创建Count类型的信号量,linux中 与Count类型 一致
115 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
116 * @param[in] lInitialCount 初始值
117 * @param[in] pFunc 调用该API的文件名
118 * @param[in] iLine 调用该API的行号
119 * @return 返回SEM_ID,失败则返回 0
121 ULONG __VOS_SemCCreate(LONG lOption, LONG lInitialCount,const CHAR *pFunc, INT iLine);
125 * 不要直接调用该API,通过宏 VOS_SemMCreate 使用
127 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
128 * @param[in] pFunc 调用该API的文件名
129 * @param[in] iLine 调用该API的行号
130 * @return 返回SEM_ID,失败则返回 0
132 ULONG __VOS_SemMCreate(LONG lOption,const CHAR *pFunc, INT iLine);
136 #endif /* __cplusplus */
139 #endif /* __VOS_SEM_H__ */