提交 844c5952 编写于 作者: O openharmony_ci 提交者: Gitee

!356 系统pend类接口未对软件定时器任务进行限制,容易引发软件定时器任务非正常挂起,出现响应不及时的问题。

Merge pull request !356 from zhangfanfan2/swtmr
......@@ -155,6 +155,15 @@ extern "C" {
*/
#define LOS_ERRNO_EVENT_SHOULD_NOT_DESTROYED LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x08)
/**
* @ingroup los_event
* Event reading error code: The event is being read in a system-level task.
* Value: 0x02001c09
*
* Solution: Read the event in a valid task.
*/
#define LOS_ERRNO_EVENT_READ_IN_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x09)
/**
* @ingroup los_event
* Event control structure
......
......@@ -172,6 +172,16 @@ extern "C" {
*/
#define LOS_ERRNO_MUX_MAXNUM_ZERO LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x0C)
/**
* @ingroup los_mux
*
* Mutex error code: The API is called in a system-level task, which is forbidden.
* Value: 0x02001d0D
*
* Solution: Do not call the API in system-level tasks.
*/
#define LOS_ERRNO_MUX_PEND_IN_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x0D)
/**
* @ingroup los_mux
* @brief Create a mutex.
......
......@@ -156,6 +156,15 @@ extern "C" {
*/
#define LOS_ERRNO_SEM_MAXNUM_ZERO LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x0A)
/**
* @ingroup los_sem
* Semaphore error code: The API is called in a system-level task, which is forbidden.
* Value: 0x0200070B
*
* Solution: Do not call the API in system-level tasks.
*/
#define LOS_ERRNO_SEM_PEND_IN_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x0B)
/**
* @ingroup los_sem
* @brief Create a Counting semaphore.
......
......@@ -241,13 +241,14 @@ extern "C" {
/**
* @ingroup los_task
* Task error code: The operation is performed on the idle task.
* Task error code: The operation is performed on the system-level task.
*
* Value: 0x02000214
*
* Solution: Check the task ID and do not operate on the idle task.
* Solution: Check the task ID and do not operate on the system-level task.
*/
#define LOS_ERRNO_TSK_OPERATE_IDLE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x14)
#define LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x14)
#define LOS_ERRNO_TSK_OPERATE_IDLE LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK
/**
* @ingroup los_task
......@@ -1284,6 +1285,14 @@ extern UINT32 LOS_TaskDetach(UINT32 taskID);
*/
#define OS_TASK_STATUS_EXIT 0x0100
/**
* @ingroup los_task
* Flag that indicates the task property.
*
* The task is system-level task, like idle, swtmr and etc.
*/
#define OS_TASK_FLAG_SYSTEM_TASK 0x1000U
/**
* @ingroup los_task
* Flag that indicates the task or task control block status.
......
......@@ -108,6 +108,9 @@ LITE_OS_SEC_TEXT UINT32 LOS_EventRead(PEVENT_CB_S eventCB, UINT32 eventMask, UIN
if (OS_INT_ACTIVE) {
return LOS_ERRNO_EVENT_READ_IN_INTERRUPT;
}
if (g_losTask.runTask->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
return LOS_ERRNO_EVENT_READ_IN_SYSTEM_TASK;
}
intSave = LOS_IntLock();
ret = LOS_EventPoll(&(eventCB->uwEventID), eventMask, mode);
OsHookCall(LOS_HOOK_TYPE_EVENT_READ, eventCB, eventMask, mode, timeOut);
......@@ -204,6 +207,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_EventDestroy(PEVENT_CB_S eventCB)
OsHookCall(LOS_HOOK_TYPE_EVENT_DESTROY, eventCB);
return LOS_OK;
}
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_EventClear(PEVENT_CB_S eventCB, UINT32 eventMask)
{
UINT32 intSave;
......@@ -216,5 +220,3 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_EventClear(PEVENT_CB_S eventCB, UINT32 eventMa
LOS_IntRestore(intSave);
return LOS_OK;
}
......@@ -172,6 +172,10 @@ STATIC_INLINE UINT32 OsMuxValidCheck(LosMuxCB *muxPended)
return LOS_ERRNO_MUX_PEND_IN_LOCK;
}
if (g_losTask.runTask->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
return LOS_ERRNO_MUX_PEND_IN_SYSTEM_TASK;
}
return LOS_OK;
}
......
......@@ -202,6 +202,9 @@ STATIC_INLINE UINT32 OsSemValidCheck(LosSemCB *semPended)
return LOS_ERRNO_SEM_PEND_IN_LOCK;
}
if (g_losTask.runTask->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
return LOS_ERRNO_SEM_PEND_IN_SYSTEM_TASK;
}
return LOS_OK;
}
......
......@@ -116,6 +116,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrTaskCreate(VOID)
swtmrTask.pcName = "Swt_Task";
swtmrTask.usTaskPrio = 0;
ret = LOS_TaskCreate(&g_swtmrTaskID, &swtmrTask);
if (ret == LOS_OK) {
OS_TCB_FROM_TID(g_swtmrTaskID)->taskStatus |= OS_TASK_FLAG_SYSTEM_TASK;
}
return ret;
}
......@@ -667,5 +670,3 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrDelete(UINT32 swtmrId)
}
#endif /* (LOSCFG_BASE_CORE_SWTMR == 1) */
......@@ -876,11 +876,17 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskSuspend(UINT32 taskID)
taskCB = OS_TCB_FROM_TID(taskID);
intSave = LOS_IntLock();
tempStatus = taskCB->taskStatus;
if (tempStatus & OS_TASK_STATUS_UNUSED) {
retErr = LOS_ERRNO_TSK_NOT_CREATED;
OS_GOTO_ERREND();
}
if (tempStatus & OS_TASK_FLAG_SYSTEM_TASK) {
retErr = LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
OS_GOTO_ERREND();
}
if (tempStatus & OS_TASK_STATUS_SUSPEND) {
retErr = LOS_ERRNO_TSK_ALREADY_SUSPENDED;
OS_GOTO_ERREND();
......@@ -1069,6 +1075,10 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
taskCB = OS_TCB_FROM_TID(taskID);
intSave = LOS_IntLock();
if (taskCB->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
LOS_IntRestore(intSave);
return LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
}
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
LOS_IntRestore(intSave);
......@@ -1133,6 +1143,9 @@ LITE_OS_SEC_TEXT UINT32 LOS_TaskDelay(UINT32 tick)
return LOS_ERRNO_TSK_DELAY_IN_LOCK;
}
if (g_losTask.runTask->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
return LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
}
OsHookCall(LOS_HOOK_TYPE_TASK_DELAY, tick);
if (tick == 0) {
return LOS_TaskYield();
......@@ -1201,6 +1214,10 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskPriSet(UINT32 taskID, UINT16 taskPrio)
LOS_IntRestore(intSave);
return LOS_ERRNO_TSK_NOT_CREATED;
}
if (tempStatus & OS_TASK_FLAG_SYSTEM_TASK) {
LOS_IntRestore(intSave);
return LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
}
isReady = OsSchedModifyTaskSchedParam(taskCB, taskPrio);
LOS_IntRestore(intSave);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册