WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
los_priqueue_pri.h
浏览该文件的文档.
1/* ----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
3 * Description: Priority Queue Private HeadFile
4 * Author: Huawei LiteOS Team
5 * Create: 2013-01-01
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without specific prior written
15 * permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * --------------------------------------------------------------------------- */
28
29#ifndef _LOS_PRIQUEUE_PRI_H
30#define _LOS_PRIQUEUE_PRI_H
31
32#include "los_list.h"
33#include "los_typedef.h"
34#include "los_spinlock.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif /* __cplusplus */
39
44
45/* Number of priority queues. Now LiteOS only supports 32 priorities. */
46#define OS_PRIORITY_QUEUE_NUM 32
47#define PRIQUEUE_PRIOR0_BIT 0x80000000U
48
49/* This API is used to initialize the priority queue. */
51
52/* This API is used to delete a item from the priority queue. */
53extern VOID OsPriQueueDequeue(LOS_DL_LIST *priqueueItem);
54
55/*
56 * These two functions are protect version of OsPriQueueEnqueue and OsPriQueueDequeue.
57 * In SCHED_SQ, the task status and priqueue are protected by the global schedule lock, this two function
58 * are just the same as the previous ones.
59 */
60#ifdef LOSCFG_SCHED_MQ
61
62struct tagTaskCB;
63
64typedef struct {
65 UINT32 bitmap; /* priority-queue bitmap */
66 LOS_DL_LIST queues[OS_PRIORITY_QUEUE_NUM]; /* one for each priority */
67 INT32 readyTasks; /* number of ready tasks */
68 SPIN_LOCK_S lock; /* private spinlock */
69 struct tagTaskCB *prevTask; /* previously ran task */
70} PriQueue;
71
72/* Per-cpu priority queue */
73extern PriQueue g_priQueue[LOSCFG_KERNEL_CORE_NUM];
74
75/*
76 * This API is used to get whether the priority queue is empty.
77 */
79{
80 PriQueue *priQueue = &g_priQueue[ArchCurrCpuid()];
81
82 return ((priQueue->bitmap & (PRIQUEUE_PRIOR0_BIT >> priority)) == 0);
83}
84
85extern VOID OsPriQueueSimpleEnqueue(LOS_DL_LIST *queueNode, PriQueueHeadTail mode);
87extern BOOL OsPriQueueDequeueProtect(LOS_DL_LIST *priqueueItem);
88
89#else /* LOSCFG_SCHED_SQ */
90/* This API is used to insert a item to the priority queue according to the priority of this item. */
92
93/*
94 * This API is used to get whether the priority queue is empty.
95 */
97
102
104{
105 OsPriQueueDequeue(priqueueItem);
106 return TRUE;
107}
108#endif /* LOSCFG_SCHED_MQ */
109
110/*
111 * This API is used to obtain the item with highest priority in the priority queue.
112 */
114
115#ifdef __cplusplus
116}
117#endif /* __cplusplus */
118
119#endif /* _LOS_PRIQUEUE_PRI_H */
#define STATIC
Definition common_def.h:57
#define INLINE
Definition common_def.h:65
#define LOSCFG_KERNEL_CORE_NUM
Definition los_config.h:258
LOS_DL_LIST * OsPriQueueTop(VOID)
#define OS_PRIORITY_QUEUE_NUM
Definition los_priqueue_pri.h:46
STATIC INLINE VOID OsPriQueueEnqueueProtect(LOS_DL_LIST *queueNode, UINT32 priority, PriQueueHeadTail mode)
Definition los_priqueue_pri.h:98
VOID OsPriQueueEnqueue(LOS_DL_LIST *priqueueItem, UINT32 priority, PriQueueHeadTail mode)
STATIC INLINE BOOL OsPriQueueDequeueProtect(LOS_DL_LIST *priqueueItem)
Definition los_priqueue_pri.h:103
#define PRIQUEUE_PRIOR0_BIT
Definition los_priqueue_pri.h:47
PriQueueHeadTail
Definition los_priqueue_pri.h:40
@ PRI_QUEUE_TAIL
Definition los_priqueue_pri.h:42
@ PRI_QUEUE_HEAD
Definition los_priqueue_pri.h:41
BOOL OsPriQueueIsEmpty(UINT32 priority)
VOID OsPriQueueInit(VOID)
VOID OsPriQueueDequeue(LOS_DL_LIST *priqueueItem)
signed int INT32
Definition los_typedef.h:55
#define VOID
Definition los_typedef.h:88
#define TRUE
Definition los_typedef.h:98
unsigned int UINT32
Definition los_typedef.h:52
size_t BOOL
Definition los_typedef.h:83
Definition los_list.h:47
Definition los_spinlock.h:78
Definition los_task_base.h:131
UINT16 priority
Definition los_task_base.h:139