1 /******************************************************************************
3 * Copyright (c) 2020 ICT/CAS.
5 * Licensed under the O-RAN Software License, Version 1.0 (the "Software License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * https://www.o-ran.org/software
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 *******************************************************************************/
27 #endif /* __cplusplus */
33 #define VOS_QUEUE_MSG_SIZE 4
36 #define VOS_HAVE_MSG (VOS_QUEUE_MSG_SIZE * sizeof(ULONG))
38 /** 队列类型,linux中只支持 VOS_MSG_Q_FIFO 和 VOS_MSG_Q_PRIORITY 类型 */
40 VOS_MSG_Q_FIFO = 0, ///< first in first out queue
41 VOS_MSG_Q_PRIORITY = 1, ///< priority sorted queue
42 VOS_MSG_Q_PIPE = 2, ///< pipe queue
43 VOS_MSG_Q_ISOCK = 3, ///< ISOCK queue
48 MSG_PRI_NORMAL = 0, ///< 普通优先级
49 MSG_PRI_URGENT = 1, ///< 高优先级
55 * @param[in] lMaxMsgs 消息队列中最大消息数目
56 * @param[in] lOptions 选项,VOS_msgq_type_t 类型,linux中支持MSG_Q_FIFO和MSG_Q_PRIORITY
57 * @return 成功返回队列ID,失败则返回 0
59 ULONG VOS_QueCreate(LONG lMaxMsgs, LONG lOptions);
64 * @param[in] msgQId 消息队列ID
65 * @return 成功返回队列ID,失败则返回 0
67 LONG VOS_QueDelete(ULONG msgQId);
72 * @param[in] msgQId 消息队列ID
73 * @param[in] aulMsg 发送的消息,含有VOS_QUEUE_MSG_SIZE个ULONG的数组
74 * @param[in] lMsec 当队列满时,发送任务等待的时间,单位是毫秒。
75 * VOS_WAIT_FOREVER 表示永久等待。VOS_WAIT_NO_WAIT 表示不等待。
76 * @param[in] lPriority 消息的优先级。分为MSG_PRI_NORMAL和MSG_PRI_URGENT两种。
77 * @return VOS_OK - 成功,其他 - 失败
78 * @note WINDOWS中存在Bug,队列满了后,不能等待,只能返回失败
80 LONG VOS_QueSend(ULONG msgQId, ULONG aulMsg[VOS_QUEUE_MSG_SIZE], LONG lMsec, LONG lPriority);
85 * @param[in] msgQId 消息队列ID
86 * @param[in] aulMsg 接收的消息,含有VOS_QUEUE_MSG_SIZE个ULONG的数组
87 * @param[in] lMsec 当队列满时,发送任务等待的时间,单位是毫秒。
88 * VOS_WAIT_FOREVER 表示永久等待。VOS_WAIT_NO_WAIT 表示不等待。
89 * @return 失败为VOS_ERROR;成功时如果消息队列中消息数为0 则返回VOS_NO_MSG,
90 * 如果消息队列中消息数不为0 ,则返回VOS_HAVE_MSG。
91 * @note 一般任务的入口函数就阻塞在VOS_QueReceive。
93 LONG VOS_QueReceive(ULONG msgQId, ULONG aulMsg[VOS_QUEUE_MSG_SIZE], LONG lMsec);
97 * 将队列和任务绑定,用于队列管理,一般创建完队列和任务后调用
98 * @param[in] hTask 任务句柄
99 * @param[in] ulQId 消息队列ID
101 VOID VOS_QueBindTask(VOS_HANDLE hTask, ULONG ulQId);
106 * @param[in] msgQId 消息队列ID
107 * @return 成功则返回消息队列中消息的数目,失败则VOS_ERROR。
109 LONG VOS_QueNum(ULONG msgQId);
119 #endif /* __cplusplus */
121 #endif /* __VOS_QUE_H__ */