• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2009-2022 Huawei Technologies Co., Ltd. All rights reserved.
3  *
4  * UniProton is licensed under Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *          http://license.coscl.org.cn/MulanPSL2
8  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11  * See the Mulan PSL v2 for more details.
12  * Create: 2009-12-22
13  * Description: task模块的模块内头文件
14  */
15 #ifndef PRT_TASK_INTERNAL_H
16 #define PRT_TASK_INTERNAL_H
17 
18 #include "prt_task_external.h"
19 #include "prt_asm_cpu_external.h"
20 
21 /*
22  * 模块内宏定义
23  */
24 #define OS_TSK_STACK_MAGIC g_tskModInfo.magicWord
25 #define OS_TSK_STACK_CFG_BY_USER 1
26 #define OS_TSK_STACK_CFG_BY_SYS 0
27 
28 /*
29  * 模块内全局变量声明
30  */
31 extern struct TagListObject g_tskCbFreeList;
32 extern struct TagListObject g_tskRecyleList;
33 
34 /*
35  * 模块内函数声明
36  */
37 extern void *OsTskMemAlloc(U32 size);
38 extern void OsTskIdleBgd(void);
39 extern U32 OsTaskDelStatusCheck(struct TagTskCb *taskCb);
40 
OsMoveTaskToReady(struct TagTskCb * taskCb)41 OS_SEC_ALW_INLINE INLINE void OsMoveTaskToReady(struct TagTskCb *taskCb)
42 {
43     /* If task is not blocked then move it to ready list */
44     if ((taskCb->taskStatus & OS_TSK_BLOCK) == 0) {
45         OsTskReadyAdd(taskCb);
46 
47         if ((OS_FLG_BGD_ACTIVE & UNI_FLAG) != 0) {
48             OsTskSchedule();
49             return;
50         }
51     }
52 }
53 
OsTskResRecycle(struct TagTskCb * taskCb)54 OS_SEC_ALW_INLINE INLINE void OsTskResRecycle(struct TagTskCb *taskCb)
55 {
56     if (taskCb->stackCfgFlg == OS_TSK_STACK_CFG_BY_SYS) {
57         OS_ERR_RECORD(PRT_MemFree((U32)OS_MID_TSK, (void *)taskCb->topOfStack));
58     }
59 }
60 #endif /* PRT_TASK_INTERNAL_H */
61