1 /* 2 * Copyright (c) 2009-2022 Huawei Technologies Co., Ltd. All rights reserved. 3 * 4 * UniProton is licensed under Mulan PSL v2. 5 * You can use this software according to the terms and conditions of the Mulan PSL v2. 6 * You may obtain a copy of Mulan PSL v2 at: 7 * http://license.coscl.org.cn/MulanPSL2 8 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 9 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 10 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 11 * See the Mulan PSL v2 for more details. 12 * Create: 2009-12-22 13 * Description: 信号量模块内部头文件 14 */ 15 #ifndef PRT_SEM_EXTERNAL_H 16 #define PRT_SEM_EXTERNAL_H 17 18 #include "prt_sem.h" 19 #include "prt_task_external.h" 20 21 #define OS_SEM_UNUSED 0 22 #define OS_SEM_USED 1 23 24 #define OS_SEM_WITH_LOCK_FLAG 1 25 #define OS_SEM_WITHOUT_LOCK_FLAG 0 26 27 #define GET_SEM_LIST(ptr) LIST_COMPONENT(ptr, struct TagSemCb, semList) 28 #define GET_SEM(semid) (((struct TagSemCb *)g_allSem) + (semid)) 29 #define GET_SEM_TSK(semid) (((SEM_TSK_S *)g_semTsk) + (semid)) 30 #define GET_TSK_SEM(tskid) (((TSK_SEM_S *)g_tskSem) + (tskid)) 31 32 struct TagSemCb { 33 /* 是否使用 OS_SEM_UNUSED/OS_SEM_USED */ 34 U16 semStat; 35 /* 核内信号量索引号 */ 36 U16 semId; 37 /* 当该信号量已用时,其信号量计数 */ 38 U32 semCount; 39 /* 挂接阻塞于该信号量的任务 */ 40 struct TagListObject semList; 41 U32 maxSemCount; 42 43 /* Pend到该信号量的线程ID */ 44 U32 semOwner; 45 /* 信号量唤醒阻塞任务的方式 */ 46 enum SemMode semMode; 47 }; 48 49 /* 模块间全局变量声明 */ 50 extern U16 g_maxSem; 51 52 /* 指向核内信号量控制块 */ 53 extern struct TagSemCb *g_allSem; 54 #endif /* PRT_SEM_EXTERNAL_H */ 55