11bd4fe43Sopenharmony_ci/**
21bd4fe43Sopenharmony_ci * @file hi_mux.h
31bd4fe43Sopenharmony_ci *
41bd4fe43Sopenharmony_ci * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
51bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
61bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License.
71bd4fe43Sopenharmony_ci * You may obtain a copy of the License at
81bd4fe43Sopenharmony_ci *
91bd4fe43Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
101bd4fe43Sopenharmony_ci *
111bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
121bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
131bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
141bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and
151bd4fe43Sopenharmony_ci * limitations under the License.
161bd4fe43Sopenharmony_ci */
171bd4fe43Sopenharmony_ci
181bd4fe43Sopenharmony_ci/**
191bd4fe43Sopenharmony_ci * @defgroup iot_mux Mutex
201bd4fe43Sopenharmony_ci * @ingroup osa
211bd4fe43Sopenharmony_ci */
221bd4fe43Sopenharmony_ci
231bd4fe43Sopenharmony_ci#ifndef __HI_MUX_H__
241bd4fe43Sopenharmony_ci#define __HI_MUX_H__
251bd4fe43Sopenharmony_ci#include <hi_types_base.h>
261bd4fe43Sopenharmony_ci
271bd4fe43Sopenharmony_ci/**
281bd4fe43Sopenharmony_ci* @ingroup  iot_mux
291bd4fe43Sopenharmony_ci* @brief  Creates a mutex.CNcomment:创建互斥锁。CNend
301bd4fe43Sopenharmony_ci*
311bd4fe43Sopenharmony_ci* @par 描述:
321bd4fe43Sopenharmony_ci*           Creates a mutex.CNcomment:创建互斥锁。CNend
331bd4fe43Sopenharmony_ci*
341bd4fe43Sopenharmony_ci* @attention None
351bd4fe43Sopenharmony_ci* @param  mux_id  [OUT] type #hi_u32*,Mutex handle.CNcomment:互斥锁句柄。CNend
361bd4fe43Sopenharmony_ci*
371bd4fe43Sopenharmony_ci* @retval #0      Success
381bd4fe43Sopenharmony_ci* @retval #Other  Failure. For details, see hi_errno.h.
391bd4fe43Sopenharmony_ci* @par 依赖:
401bd4fe43Sopenharmony_ci*            @li hi_mux.h:Describes mutex APIs.CNcomment:文件用于描述互斥锁相关接口。CNend
411bd4fe43Sopenharmony_ci* @see  hi_mux_delete。
421bd4fe43Sopenharmony_ci*/
431bd4fe43Sopenharmony_cihi_u32 hi_mux_create (hi_u32 *mux_id);
441bd4fe43Sopenharmony_ci
451bd4fe43Sopenharmony_ci/**
461bd4fe43Sopenharmony_ci* @ingroup  iot_mux
471bd4fe43Sopenharmony_ci* @brief  Deletes a mutex.CNcomment:删除互斥锁。CNend
481bd4fe43Sopenharmony_ci*
491bd4fe43Sopenharmony_ci* @par 描述:
501bd4fe43Sopenharmony_ci*           Deletes a mutex.CNcomment:删除互斥锁。CNend
511bd4fe43Sopenharmony_ci*
521bd4fe43Sopenharmony_ci* @attention None
531bd4fe43Sopenharmony_ci*
541bd4fe43Sopenharmony_ci* @param  mux_id  [IN] type #hi_u32,Mutex handle.CNcomment:互斥锁句柄。CNend
551bd4fe43Sopenharmony_ci*
561bd4fe43Sopenharmony_ci* @retval #0      Success
571bd4fe43Sopenharmony_ci* @retval #Other  Failure. For details, see hi_errno.h.
581bd4fe43Sopenharmony_ci* @par 依赖:
591bd4fe43Sopenharmony_ci*            @li hi_mux.h:Describes mutex APIs.CNcomment:文件用于描述互斥锁相关接口。CNend
601bd4fe43Sopenharmony_ci* @see  hi_mux_create。
611bd4fe43Sopenharmony_ci*/
621bd4fe43Sopenharmony_cihi_u32 hi_mux_delete(hi_u32 mux_id);
631bd4fe43Sopenharmony_ci
641bd4fe43Sopenharmony_ci/**
651bd4fe43Sopenharmony_ci* @ingroup  iot_mux
661bd4fe43Sopenharmony_ci* @brief  Waits for a mutex.CNcomment:等待互斥锁。CNend
671bd4fe43Sopenharmony_ci*
681bd4fe43Sopenharmony_ci* @par 描述:
691bd4fe43Sopenharmony_ci*           Waits for a mutex.CNcomment:等待互斥锁。CNend
701bd4fe43Sopenharmony_ci*
711bd4fe43Sopenharmony_ci* @attention Mutexes support priority inversion.CNcomment:互斥锁支持优先级翻转。CNend
721bd4fe43Sopenharmony_ci* @param  mux_id     [IN] type #hi_u32,Mutex handle.CNcomment:互斥锁句柄。CNend
731bd4fe43Sopenharmony_ci* @param  timeout_ms [IN] type #hi_u32,Timeout period (unit: ms). HI_SYS_WAIT_FOREVER indicates permanent waiting.
741bd4fe43Sopenharmony_ciCNcomment:超时时间(单位:ms)。HI_SYS_WAIT_FOREVER为永久等待。CNend
751bd4fe43Sopenharmony_ci*
761bd4fe43Sopenharmony_ci* @retval #0      Success
771bd4fe43Sopenharmony_ci* @retval #Other  Failure. For details, see hi_errno.h.
781bd4fe43Sopenharmony_ci* @par 依赖:
791bd4fe43Sopenharmony_ci*            @li hi_mux.h:Describes mutex APIs.CNcomment:文件用于描述互斥锁相关接口。CNend
801bd4fe43Sopenharmony_ci* @see  hi_mux_post。
811bd4fe43Sopenharmony_ci*/
821bd4fe43Sopenharmony_cihi_u32 hi_mux_pend(hi_u32 mux_id, hi_u32 timeout_ms);
831bd4fe43Sopenharmony_ci
841bd4fe43Sopenharmony_ci/**
851bd4fe43Sopenharmony_ci* @ingroup  iot_mux
861bd4fe43Sopenharmony_ci* @brief  Releases a mutex.CNcomment:释放互斥锁。CNend
871bd4fe43Sopenharmony_ci*
881bd4fe43Sopenharmony_ci* @par 描述:
891bd4fe43Sopenharmony_ci*           Releases a mutex.CNcomment:释放互斥锁。CNend
901bd4fe43Sopenharmony_ci*
911bd4fe43Sopenharmony_ci* @attention A mutex can be released only in the task that has obtained the mutex.
921bd4fe43Sopenharmony_ciCNcomment:互斥锁只能在获取到互斥锁的任务中释放。CNend
931bd4fe43Sopenharmony_ci*
941bd4fe43Sopenharmony_ci* @param  mux_id  [IN] type #hi_u32,Mutex handle.CNcomment:互斥锁句柄。CNend
951bd4fe43Sopenharmony_ci*
961bd4fe43Sopenharmony_ci* @retval #0      Success
971bd4fe43Sopenharmony_ci* @retval #Other  Failure. For details, see hi_errno.h.
981bd4fe43Sopenharmony_ci* @par 依赖:
991bd4fe43Sopenharmony_ci*            @li hi_mux.h:Describes mutex APIs.CNcomment:文件用于描述互斥锁相关接口。CNend
1001bd4fe43Sopenharmony_ci* @see  hi_mux_pend。
1011bd4fe43Sopenharmony_ci*/
1021bd4fe43Sopenharmony_cihi_u32 hi_mux_post(hi_u32 mux_id);
1031bd4fe43Sopenharmony_ci
1041bd4fe43Sopenharmony_ci#endif
105