更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_queue_pri.h 文件参考

浏览源代码.

结构体

struct  LosQueueCB
 

枚举

enum  QueueReadWrite { OS_QUEUE_READ = 0 , OS_QUEUE_WRITE = 1 , OS_QUEUE_N_RW = 2 }
 @note_pic 更多...
 
enum  QueueHeadTail { OS_QUEUE_HEAD = 0 , OS_QUEUE_TAIL = 1 }
 

函数

VOID * OsQueueMailAlloc (UINT32 queueID, VOID *mailPool, UINT32 timeout)
 Alloc a stationary memory for a mail. 更多...
 
UINT32 OsQueueMailFree (UINT32 queueID, VOID *mailPool, VOID *mailMem)
 Free a stationary memory of a mail. 更多...
 
UINT32 OsQueueInit (VOID)
 

变量

LosQueueCBg_allQueue
 消息队列池 更多...
 

枚举类型说明

◆ QueueHeadTail

枚举值
OS_QUEUE_HEAD 

队列头部标识

OS_QUEUE_TAIL 

队列尾部标识

在文件 los_queue_pri.h68 行定义.

68 {
69 OS_QUEUE_HEAD = 0, ///< 队列头部标识
70 OS_QUEUE_TAIL = 1 ///< 队列尾部标识
QueueHeadTail
Definition: los_queue_pri.h:68
@ OS_QUEUE_TAIL
队列尾部标识
Definition: los_queue_pri.h:70
@ OS_QUEUE_HEAD
队列头部标识
Definition: los_queue_pri.h:69

◆ QueueReadWrite

@note_pic

 鸿蒙对消息队列图
                           |<-----消息内容区,有2个消息---->|
+------------+------------------------------------------------------------+
|            |             |---------------|---------------|              |
|            |             |---------------|---------------|              |
|            |             |---------------|---------------|              |
+-------------------------------------------------------------------------+
|            |             ^                               ^              |
|<消息大小>      |             |                               |              |
|            |             |head                           |tail          |
|            +             +任务读消息                          +任务写消息         |
|                                                                         |
|                                                                         |
+<-------------+      队列长度,消息点个数,                          +------------->+
 * 
枚举值
OS_QUEUE_READ 

读队列

OS_QUEUE_WRITE 

写队列

OS_QUEUE_N_RW 

在文件 los_queue_pri.h62 行定义.

62 {
63 OS_QUEUE_READ = 0, ///< 读队列
64 OS_QUEUE_WRITE = 1, ///< 写队列
QueueReadWrite
@note_pic
Definition: los_queue_pri.h:62
@ OS_QUEUE_N_RW
Definition: los_queue_pri.h:65
@ OS_QUEUE_WRITE
写队列
Definition: los_queue_pri.h:64
@ OS_QUEUE_READ
读队列
Definition: los_queue_pri.h:63

函数说明

◆ OsQueueInit()

UINT32 OsQueueInit ( VOID  )

在文件 los_queue.c105 行定义.

106{
107 LosQueueCB *queueNode = NULL;
108 UINT32 index;
109 UINT32 size;
110
111 size = LOSCFG_BASE_IPC_QUEUE_LIMIT * sizeof(LosQueueCB);//支持1024个IPC队列
112 /* system resident memory, don't free */
113 g_allQueue = (LosQueueCB *)LOS_MemAlloc(m_aucSysMem0, size);//常驻内存
114 if (g_allQueue == NULL) {
115 return LOS_ERRNO_QUEUE_NO_MEMORY;
116 }
117 (VOID)memset_s(g_allQueue, size, 0, size);//清0
118 LOS_ListInit(&g_freeQueueList);//初始化空闲链表
119 for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_LIMIT; index++) {//循环初始化每个消息队列
120 queueNode = ((LosQueueCB *)g_allQueue) + index;//一个一个来
121 queueNode->queueID = index;//这可是 队列的身份证
122 LOS_ListTailInsert(&g_freeQueueList, &queueNode->readWriteList[OS_QUEUE_WRITE]);//通过写节点挂到空闲队列链表上
123 }//这里要注意是用 readWriteList 挂到 g_freeQueueList链上的,所以要通过 GET_QUEUE_LIST 来找到 LosQueueCB
124
125 if (OsQueueDbgInitHook() != LOS_OK) {//调试队列使用的.
126 return LOS_ERRNO_QUEUE_NO_MEMORY;
127 }
128 return LOS_OK;
129}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
Definition: los_list.h:104
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
Insert a node to the tail of a doubly linked list.
Definition: los_list.h:244
VOID * LOS_MemAlloc(VOID *pool, UINT32 size)
从指定内存池中申请size长度的内存,注意这可不是从内核堆空间中申请内存
Definition: los_memory.c:1123
UINT8 * m_aucSysMem0
异常交互动态内存池地址的起始地址,当不支持异常交互特性时,m_aucSysMem0等于m_aucSysMem1。
Definition: los_memory.c:107
LITE_OS_SEC_BSS LosQueueCB * g_allQueue
消息队列池
Definition: los_queue.c:98
LITE_OS_SEC_BSS STATIC LOS_DL_LIST g_freeQueueList
空闲队列链表,管分配的,需要队列从这里申请
Definition: los_queue.c:99
STATIC INLINE UINT32 OsQueueDbgInitHook(VOID)
unsigned int UINT32
Definition: los_typedef.h:57
UINT32 queueID
Definition: los_queue_pri.h:93
LOS_DL_LIST readWriteList[OS_QUEUE_N_RW]
Definition: los_queue_pri.h:98
函数调用图:
这是这个函数的调用关系图: