鸿蒙研究站
|
官方文档
|
源码分析
== 鸿蒙内核参考手册 ==
内核注释
|
论坛
|
赞助作者
更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_sem_pri.h
浏览该文件的文档.
1
/*
2
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without modification,
6
* are permitted provided that the following conditions are met:
7
*
8
* 1. Redistributions of source code must retain the above copyright notice, this list of
9
* conditions and the following disclaimer.
10
*
11
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
* of conditions and the following disclaimer in the documentation and/or other materials
13
* provided with the distribution.
14
*
15
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
16
* to endorse or promote products derived from this software without specific prior written
17
* permission.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32
#ifndef _LOS_SEM_PRI_H
33
#define _LOS_SEM_PRI_H
34
35
#include "
los_sem.h
"
36
37
#ifdef __cplusplus
38
#if __cplusplus
39
extern
"C"
{
40
#endif
/* __cplusplus */
41
#endif
/* __cplusplus */
42
43
/**
44
* @ingroup los_sem
45
* Semaphore control structure.
46
*/
47
typedef
struct
{
48
UINT8
semStat
;
/**< Semaphore state | 信号量的状态 */
49
UINT16
semCount
;
/**< Number of available semaphores | 有效信号量的数量 */
50
UINT16
maxSemCount
;
/**< Max number of available semaphores | 有效信号量的最大数量 */
51
UINT32
semID
;
/**< Semaphore control structure ID | 信号量索引号 */
52
LOS_DL_LIST
semList
;
/**< Queue of tasks that are waiting on a semaphore | 挂接阻塞于该信号量的任务 */
53
}
LosSemCB
;
54
55
/**
56
* @ingroup los_sem
57
* The semaphore is not in use.
58
*
59
*/
60
#define OS_SEM_UNUSED 0
61
/**
62
* @ingroup los_sem
63
* The semaphore is used.
64
*
65
*/
66
#define OS_SEM_USED 1
67
/**
68
* @ingroup los_sem
69
* Obtain the head node in a semaphore doubly linked list.
70
*
71
*/
72
#define GET_SEM_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosSemCB, semList)
73
extern
LosSemCB
*
g_allSem
;
74
/**
75
* @ingroup los_sem
76
* COUNT | INDEX split bit
77
*/
78
#define SEM_SPLIT_BIT 16
79
/**
80
* @ingroup los_sem
81
* Set the semaphore id
82
*/
83
#define SET_SEM_ID(count, semID) (((count) << SEM_SPLIT_BIT) | (semID))
84
85
/**
86
* @ingroup los_sem
87
* get the semaphore index
88
*/
89
#define GET_SEM_INDEX(semID) ((semID) & ((1U << SEM_SPLIT_BIT) - 1))
90
91
/**
92
* @ingroup los_sem
93
* get the semaphore count
94
*/
95
#define GET_SEM_COUNT(semID) ((semID) >> SEM_SPLIT_BIT)
96
97
/**
98
* @ingroup los_sem
99
* Obtain a semaphore ID.
100
*
101
*/
102
#define GET_SEM(semID) (((LosSemCB *)g_allSem) + GET_SEM_INDEX(semID))
103
104
/**
105
* @ingroup los_sem
106
* Maximum value of task information.
107
*
108
*/
109
#define OS_MAX_PENDTASK_INFO 4
110
111
extern
UINT32
OsSemInit
(VOID);
112
extern
UINT32
OsSemPostUnsafe
(
UINT32
semHandle,
BOOL
*needSched);
113
114
#ifdef __cplusplus
115
#if __cplusplus
116
}
117
#endif
/* __cplusplus */
118
#endif
/* __cplusplus */
119
120
#endif
/* _LOS_SEM_PRI_H */
los_sem.h
OsSemInit
UINT32 OsSemInit(VOID)
Definition:
los_sem.c:103
OsSemPostUnsafe
UINT32 OsSemPostUnsafe(UINT32 semHandle, BOOL *needSched)
以不安全的方式释放指定的信号量,所谓不安全指的是不用自旋锁
Definition:
los_sem.c:287
g_allSem
LosSemCB * g_allSem
信号池,一次分配 LOSCFG_BASE_IPC_SEM_LIMIT 个信号量
Definition:
los_sem.c:97
UINT16
unsigned short UINT16
Definition:
los_typedef.h:56
UINT8
unsigned char UINT8
Definition:
los_typedef.h:55
UINT32
unsigned int UINT32
Definition:
los_typedef.h:57
BOOL
size_t BOOL
Definition:
los_typedef.h:88
LOS_DL_LIST
Definition:
los_list.h:82
LosSemCB
Definition:
los_sem_pri.h:47
LosSemCB::semCount
UINT16 semCount
Definition:
los_sem_pri.h:49
LosSemCB::semID
UINT32 semID
Definition:
los_sem_pri.h:51
LosSemCB::semStat
UINT8 semStat
Definition:
los_sem_pri.h:48
LosSemCB::semList
LOS_DL_LIST semList
Definition:
los_sem_pri.h:52
LosSemCB::maxSemCount
UINT16 maxSemCount
Definition:
los_sem_pri.h:50
kernel
base
include
los_sem_pri.h
公众号:鸿蒙研究站(weharmonyos)
|
论坛: bbs.weharmonyos.com
| 制作者
鸿蒙研究站 | weharmonyos.com