1/** 2 * @file hi_mux.h 3 * 4 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 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. 16 */ 17 18/** 19 * @defgroup iot_mux Mutex 20 * @ingroup osa 21 */ 22 23#ifndef __HI_MUX_H__ 24#define __HI_MUX_H__ 25#include <hi_types_base.h> 26 27/** 28* @ingroup iot_mux 29* @brief Creates a mutex.CNcomment:创建互斥锁。CNend 30* 31* @par 描述: 32* Creates a mutex.CNcomment:创建互斥锁。CNend 33* 34* @attention None 35* @param mux_id [OUT] type #hi_u32*,Mutex handle.CNcomment:互斥锁句柄。CNend 36* 37* @retval #0 Success 38* @retval #Other Failure. For details, see hi_errno.h. 39* @par 依赖: 40* @li hi_mux.h:Describes mutex APIs.CNcomment:文件用于描述互斥锁相关接口。CNend 41* @see hi_mux_delete。 42*/ 43hi_u32 hi_mux_create (hi_u32 *mux_id); 44 45/** 46* @ingroup iot_mux 47* @brief Deletes a mutex.CNcomment:删除互斥锁。CNend 48* 49* @par 描述: 50* Deletes a mutex.CNcomment:删除互斥锁。CNend 51* 52* @attention None 53* 54* @param mux_id [IN] type #hi_u32,Mutex handle.CNcomment:互斥锁句柄。CNend 55* 56* @retval #0 Success 57* @retval #Other Failure. For details, see hi_errno.h. 58* @par 依赖: 59* @li hi_mux.h:Describes mutex APIs.CNcomment:文件用于描述互斥锁相关接口。CNend 60* @see hi_mux_create。 61*/ 62hi_u32 hi_mux_delete(hi_u32 mux_id); 63 64/** 65* @ingroup iot_mux 66* @brief Waits for a mutex.CNcomment:等待互斥锁。CNend 67* 68* @par 描述: 69* Waits for a mutex.CNcomment:等待互斥锁。CNend 70* 71* @attention Mutexes support priority inversion.CNcomment:互斥锁支持优先级翻转。CNend 72* @param mux_id [IN] type #hi_u32,Mutex handle.CNcomment:互斥锁句柄。CNend 73* @param timeout_ms [IN] type #hi_u32,Timeout period (unit: ms). HI_SYS_WAIT_FOREVER indicates permanent waiting. 74CNcomment:超时时间(单位:ms)。HI_SYS_WAIT_FOREVER为永久等待。CNend 75* 76* @retval #0 Success 77* @retval #Other Failure. For details, see hi_errno.h. 78* @par 依赖: 79* @li hi_mux.h:Describes mutex APIs.CNcomment:文件用于描述互斥锁相关接口。CNend 80* @see hi_mux_post。 81*/ 82hi_u32 hi_mux_pend(hi_u32 mux_id, hi_u32 timeout_ms); 83 84/** 85* @ingroup iot_mux 86* @brief Releases a mutex.CNcomment:释放互斥锁。CNend 87* 88* @par 描述: 89* Releases a mutex.CNcomment:释放互斥锁。CNend 90* 91* @attention A mutex can be released only in the task that has obtained the mutex. 92CNcomment:互斥锁只能在获取到互斥锁的任务中释放。CNend 93* 94* @param mux_id [IN] type #hi_u32,Mutex handle.CNcomment:互斥锁句柄。CNend 95* 96* @retval #0 Success 97* @retval #Other Failure. For details, see hi_errno.h. 98* @par 依赖: 99* @li hi_mux.h:Describes mutex APIs.CNcomment:文件用于描述互斥锁相关接口。CNend 100* @see hi_mux_pend。 101*/ 102hi_u32 hi_mux_post(hi_u32 mux_id); 103 104#endif 105