提交 704cca97 编写于 作者: K kenneth

fix: 修复QUEUE_INFO_S中waitReadTask无法保存大于32的任务编号

根据任务最大数创建waitReadTask数组来保存任务编号信息

close #I41N78
Signed-off-by: Nkenneth <zhushangyuan@huawei.com>
上级 403d6dc4
......@@ -38,6 +38,7 @@
#define _LOS_QUEUE_H
#include "los_list.h"
#include "los_config.h"
#ifdef __cplusplus
#if __cplusplus
......@@ -330,6 +331,18 @@ extern "C" {
*/
#define LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1f)
/**
* @ingroup los_queue
* In struct QUEUE_INFO_S, the length of each waitReadTask/waitWriteTask/waitMemTask array depends on the value
* LOSCFG_BASE_CORE_TSK_LIMIT. The type of each array element is UINT32, which means that each element could mark 32(=2^5) tasks.
* OS_WAIT_TASK_ARRAY_LEN is used to calculate the array length.
* OS_WAIT_TASK_ID_TO_ARRAY_IDX is used to transfer task ID to array index.
* OS_WAIT_TASK_ARRAY_ELEMENT_MASK is the mask for each element.
*/
#define OS_WAIT_TASK_ARRAY_LEN ((LOSCFG_BASE_CORE_TSK_LIMIT >> 5) + 1)
#define OS_WAIT_TASK_ID_TO_ARRAY_IDX(taskID) (taskID >> 5)
#define OS_WAIT_TASK_ARRAY_ELEMENT_MASK ((1 << OS_WAIT_TASK_ARRAY_LEN) - 1)
/**
* @ingroup los_queue
* Structure of the block for queue information query
......@@ -342,9 +355,9 @@ typedef struct tagQueueInfo {
UINT16 queueTail; /**< Node tail */
UINT16 writableCnt; /**< Count of writable resources */
UINT16 readableCnt; /**< Count of readable resources */
UINT32 waitReadTask; /**< Resource reading task */
UINT32 waitWriteTask; /**< Resource writing task */
UINT32 waitMemTask; /**< Memory task */
UINT32 waitReadTask[OS_WAIT_TASK_ARRAY_LEN]; /**< Resource reading task*/
UINT32 waitWriteTask[OS_WAIT_TASK_ARRAY_LEN]; /**< Resource writing task */
UINT32 waitMemTask[OS_WAIT_TASK_ARRAY_LEN]; /**< Memory task */
} QUEUE_INFO_S;
/**
......
......@@ -651,15 +651,15 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_QueueInfoGet(UINT32 queueID, QUEUE_INFO_S *que
queueInfo->writableCnt = queueCB->readWriteableCnt[OS_QUEUE_WRITE];
LOS_DL_LIST_FOR_EACH_ENTRY(tskCB, &queueCB->readWriteList[OS_QUEUE_READ], LosTaskCB, pendList) {
queueInfo->waitReadTask |= (1 << tskCB->taskID);
queueInfo->waitReadTask[OS_WAIT_TASK_ID_TO_ARRAY_IDX(tskCB->taskID)] |= (1 << (tskCB->taskID & OS_WAIT_TASK_ARRAY_ELEMENT_MASK));
}
LOS_DL_LIST_FOR_EACH_ENTRY(tskCB, &queueCB->readWriteList[OS_QUEUE_WRITE], LosTaskCB, pendList) {
queueInfo->waitWriteTask |= (1 << tskCB->taskID);
queueInfo->waitWriteTask[OS_WAIT_TASK_ID_TO_ARRAY_IDX(tskCB->taskID)] |= (1 << (tskCB->taskID & OS_WAIT_TASK_ARRAY_ELEMENT_MASK));
}
LOS_DL_LIST_FOR_EACH_ENTRY(tskCB, &queueCB->memList, LosTaskCB, pendList) {
queueInfo->waitMemTask |= (1 << tskCB->taskID);
queueInfo->waitMemTask[OS_WAIT_TASK_ID_TO_ARRAY_IDX(tskCB->taskID)] |= (1 << (tskCB->taskID & OS_WAIT_TASK_ARRAY_ELEMENT_MASK));
}
QUEUE_END:
......
......@@ -69,7 +69,7 @@ static UINT32 Testcase(VOID)
ret = LOS_QueueCreate("Q122", 1, &g_uwQueueID122, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ret = LOS_MemboxInit((VOID *)g_aucMailBoxPool, sizeof(g_aucMailBoxPool) * 1, sizeof(g_aucMailBoxPool));
ret = LOS_MemboxInit((VOID *)g_aucMailBoxPool, sizeof(g_aucMailBoxPool) * 2, sizeof(g_aucMailBoxPool));
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
memBox = OsQueueMailAlloc(g_uwQueueID122, (VOID *)g_aucMailBoxPool, LOS_NO_WAIT);
......
......@@ -55,14 +55,14 @@ static UINT32 Testcase(VOID)
ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
ICUNIT_GOTO_EQUAL(queueInfo.waitReadTask, (1 << g_testTaskID01), queueInfo.waitReadTask, EXIT2);
ICUNIT_GOTO_EQUAL(queueInfo.waitReadTask[OS_WAIT_TASK_ID_TO_ARRAY_IDX(g_testTaskID01)], 1 << (g_testTaskID01 & OS_WAIT_TASK_ARRAY_ELEMENT_MASK), queueInfo.waitReadTask, EXIT2);
ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
ICUNIT_GOTO_EQUAL(queueInfo.waitWriteTask, (1 << g_testTaskID01), queueInfo.waitWriteTask, EXIT2);
ICUNIT_GOTO_EQUAL(queueInfo.waitWriteTask[OS_WAIT_TASK_ID_TO_ARRAY_IDX(g_testTaskID01)], 1 << (g_testTaskID01 & OS_WAIT_TASK_ARRAY_ELEMENT_MASK), queueInfo.waitWriteTask, EXIT2);
EXIT2:
ret = LOS_TaskDelete(g_testTaskID01);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册