|
| 1 | +/*---------------------------------------------------------------------------- |
| 2 | + * Copyright (c) <2013-2015>, <Huawei Technologies Co., Ltd> |
| 3 | + * All rights reserved. |
| 4 | + * Redistribution and use in source and binary forms, with or without modification, |
| 5 | + * are permitted provided that the following conditions are met: |
| 6 | + * 1. Redistributions of source code must retain the above copyright notice, this list of |
| 7 | + * conditions and the following disclaimer. |
| 8 | + * 2. Redistributions in binary form must reproduce the above copyright notice, this list |
| 9 | + * of conditions and the following disclaimer in the documentation and/or other materials |
| 10 | + * provided with the distribution. |
| 11 | + * 3. Neither the name of the copyright holder nor the names of its contributors may be used |
| 12 | + * to endorse or promote products derived from this software without specific prior written |
| 13 | + * permission. |
| 14 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 15 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 16 | + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| 18 | + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 | + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 | + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 21 | + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 22 | + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 23 | + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 24 | + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | + *---------------------------------------------------------------------------*/ |
| 26 | +/*---------------------------------------------------------------------------- |
| 27 | + * Notice of Export Control Law |
| 28 | + * =============================================== |
| 29 | + * Huawei LiteOS may be subject to applicable export control laws and regulations, which might |
| 30 | + * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. |
| 31 | + * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such |
| 32 | + * applicable export control laws and regulations. |
| 33 | + *---------------------------------------------------------------------------*/ |
| 34 | + |
| 35 | +#include "los_priqueue.inc" |
| 36 | + |
| 37 | +#include "los_base.ph" |
| 38 | +#include "los_task.ph" |
| 39 | + |
| 40 | +#include "los_memory.h" |
| 41 | + |
| 42 | +LITE_OS_SEC_BSS LOS_DL_LIST *g_pstLosPriorityQueueList; |
| 43 | + |
| 44 | +VOID osPriqueueInit(VOID) |
| 45 | +{ |
| 46 | + UINT32 uwPri = 0; |
| 47 | + UINT32 uwSize = 0; |
| 48 | + |
| 49 | + uwSize = LOS_PRIORITY_QUEUE_PRIORITYNUM * sizeof(LOS_DL_LIST); |
| 50 | + g_pstLosPriorityQueueList = (LOS_DL_LIST *)LOS_MemAlloc(m_aucSysMem0, uwSize); |
| 51 | + if (NULL == g_pstLosPriorityQueueList) |
| 52 | + { |
| 53 | + return; |
| 54 | + } |
| 55 | + |
| 56 | + for (uwPri = 0; uwPri < LOS_PRIORITY_QUEUE_PRIORITYNUM; ++uwPri) |
| 57 | + { |
| 58 | + LOS_ListInit(&g_pstLosPriorityQueueList[uwPri]); |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +VOID LOS_PriqueueEnqueue(LOS_DL_LIST *ptrPQItem, UINT32 uwPri) |
| 63 | +{ |
| 64 | + LOS_ListTailInsert(&g_pstLosPriorityQueueList[uwPri], ptrPQItem); |
| 65 | +} |
| 66 | + |
| 67 | +VOID LOS_PriqueueDequeue(LOS_DL_LIST *ptrPQItem) |
| 68 | +{ |
| 69 | + LOS_ListDelete(ptrPQItem); |
| 70 | +} |
| 71 | + |
| 72 | +LOS_DL_LIST *LOS_PriqueueTop(VOID) |
| 73 | +{ |
| 74 | + UINT32 uwPri = 0; |
| 75 | + |
| 76 | + for (uwPri = 0; uwPri < LOS_PRIORITY_QUEUE_PRIORITYNUM; ++uwPri) |
| 77 | + { |
| 78 | + if (!LOS_ListEmpty(&g_pstLosPriorityQueueList[uwPri])) |
| 79 | + { |
| 80 | + return LOS_DL_LIST_FIRST(&g_pstLosPriorityQueueList[uwPri]); |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + return (LOS_DL_LIST *)NULL; |
| 85 | +} |
| 86 | + |
| 87 | +UINT32 LOS_PriqueueSize(UINT32 uwPri) |
| 88 | +{ |
| 89 | + UINT32 uwItemCnt = 0; |
| 90 | + LOS_DL_LIST *pstCurPQNode = (LOS_DL_LIST *)NULL; |
| 91 | + |
| 92 | + LOS_DL_LIST_FOR_EACH(pstCurPQNode, &g_pstLosPriorityQueueList[uwPri]) |
| 93 | + { |
| 94 | + ++uwItemCnt; |
| 95 | + } |
| 96 | + |
| 97 | + return uwItemCnt; |
| 98 | +} |
| 99 | + |
| 100 | +UINT32 LOS_PriqueueTotalSize(VOID) |
| 101 | +{ |
| 102 | + UINT32 uwPri = 0; |
| 103 | + UINT32 uwTotalSize = 0; |
| 104 | + |
| 105 | + for (uwPri = 0; uwPri < LOS_PRIORITY_QUEUE_PRIORITYNUM; ++uwPri) |
| 106 | + { |
| 107 | + uwTotalSize += LOS_PriqueueSize(uwPri); |
| 108 | + } |
| 109 | + |
| 110 | + return uwTotalSize; |
| 111 | +} |
0 commit comments