feat: 调度去进程化,优化进程线程依赖关系
1.移动LosTaskCB 至los_sched_pri.h, 解决调度与task的依赖关系 2.调度去进程化 Signed-off-by: zhushengle <zhushengle@huawei.com> Change-Id: Ibd3b618cee59f0b323e2b4fb14354c088b60b733
This commit is contained in:
@@ -80,10 +80,8 @@ typedef struct ProcessCB {
|
||||
UINT32 processID; /**< Process ID */
|
||||
UINT16 processStatus; /**< [15:4] Process Status; [3:0] The number of threads currently
|
||||
running in the process */
|
||||
UINT16 priority; /**< Process priority */
|
||||
UINT16 consoleID; /**< The console id of task belongs */
|
||||
UINT16 processMode; /**< Kernel Mode:0; User Mode:1; */
|
||||
UINT16 readyTaskNum; /**< The number of ready tasks in the current process */
|
||||
UINT32 parentProcessID; /**< Parent process ID */
|
||||
UINT32 exitCode; /**< Process exit status */
|
||||
LOS_DL_LIST pendList; /**< Block list to which the process belongs */
|
||||
@@ -149,7 +147,7 @@ typedef struct ProcessCB {
|
||||
*
|
||||
* The process is created but does not participate in scheduling.
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_INIT 0x0010U
|
||||
#define OS_PROCESS_STATUS_INIT OS_TASK_STATUS_INIT
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
@@ -157,7 +155,7 @@ typedef struct ProcessCB {
|
||||
*
|
||||
* The process is ready.
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_READY 0x0020U
|
||||
#define OS_PROCESS_STATUS_READY OS_TASK_STATUS_READY
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
@@ -165,7 +163,7 @@ typedef struct ProcessCB {
|
||||
*
|
||||
* The process is running.
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_RUNNING 0x0040U
|
||||
#define OS_PROCESS_STATUS_RUNNING OS_TASK_STATUS_RUNNING
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
@@ -173,7 +171,7 @@ typedef struct ProcessCB {
|
||||
*
|
||||
* The process is pending
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_PENDING 0x0080U
|
||||
#define OS_PROCESS_STATUS_PENDING (OS_TASK_STATUS_PENDING | OS_TASK_STATUS_DELAY | OS_TASK_STATUS_SUSPENDED)
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
@@ -181,23 +179,7 @@ typedef struct ProcessCB {
|
||||
*
|
||||
* The process is run out but the resources occupied by the process are not recovered.
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_ZOMBIES 0x100U
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
* Flag that indicates the process or process control block status.
|
||||
*
|
||||
* The number of task currently running under the process, it only works with multiple cores.
|
||||
*/
|
||||
#define OS_PROCESS_RUNTASK_COUNT_MASK 0x000FU
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
* Flag that indicates the process or process control block status.
|
||||
*
|
||||
* The process status mask.
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_MASK 0xFFF0U
|
||||
#define OS_PROCESS_STATUS_ZOMBIES 0x0100U
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
@@ -267,6 +249,11 @@ STATIC INLINE BOOL OsProcessIsDead(const LosProcessCB *processCB)
|
||||
return ((processCB->processStatus & (OS_PROCESS_FLAG_UNUSED | OS_PROCESS_STATUS_ZOMBIES)) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsProcessIsInit(const LosProcessCB *processCB)
|
||||
{
|
||||
return (processCB->processStatus & OS_PROCESS_STATUS_INIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
* The highest priority of a kernel mode process.
|
||||
@@ -297,13 +284,6 @@ STATIC INLINE BOOL OsProcessIsDead(const LosProcessCB *processCB)
|
||||
*/
|
||||
#define OS_PROCESS_USERINIT_PRIORITY 28
|
||||
|
||||
#define OS_GET_PROCESS_STATUS(status) ((UINT16)((UINT16)(status) & OS_PROCESS_STATUS_MASK))
|
||||
#define OS_PROCESS_GET_RUNTASK_COUNT(status) ((UINT16)(((UINT16)(status)) & OS_PROCESS_RUNTASK_COUNT_MASK))
|
||||
#define OS_PROCESS_RUNTASK_COUNT_ADD(status) ((UINT16)(((UINT16)(status)) & OS_PROCESS_STATUS_MASK) | \
|
||||
((OS_PROCESS_GET_RUNTASK_COUNT(status) + 1) & OS_PROCESS_RUNTASK_COUNT_MASK))
|
||||
#define OS_PROCESS_RUNTASK_COUNT_DEC(status) ((UINT16)(((UINT16)(status)) & OS_PROCESS_STATUS_MASK) | \
|
||||
((OS_PROCESS_GET_RUNTASK_COUNT(status) - 1) & OS_PROCESS_RUNTASK_COUNT_MASK))
|
||||
|
||||
#define OS_TASK_DEFAULT_STACK_SIZE 0x2000
|
||||
#define OS_USER_TASK_SYSCALL_STACK_SIZE 0x3000
|
||||
#define OS_USER_TASK_STACK_SIZE 0x100000
|
||||
@@ -410,6 +390,18 @@ STATIC INLINE UINT32 OsProcessThreadGroupIDGet(const LosTaskCB *taskCB)
|
||||
return OS_PCB_FROM_PID(taskCB->processID)->threadGroupID;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsProcessThreadNumberGet(const LosTaskCB *taskCB)
|
||||
{
|
||||
return OS_PCB_FROM_PID(taskCB->processID)->threadNumber;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC INLINE LosVmSpace *OsProcessVmSpaceGet(const LosProcessCB *processCB)
|
||||
{
|
||||
return processCB->vmSpace;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_DRIVERS_TZDRIVER
|
||||
STATIC INLINE struct Vnode *OsProcessExecVnodeGet(const LosProcessCB *processCB)
|
||||
{
|
||||
@@ -474,15 +466,14 @@ extern UINTPTR __user_init_bss;
|
||||
extern UINTPTR __user_init_end;
|
||||
extern UINTPTR __user_init_load_addr;
|
||||
extern UINT32 OsSystemProcessCreate(VOID);
|
||||
extern VOID OsProcessNaturalExit(LosProcessCB *processCB, UINT32 status);
|
||||
extern VOID OsProcessCBRecycleToFree(VOID);
|
||||
extern VOID OsProcessResourcesToFree(LosProcessCB *processCB);
|
||||
extern VOID OsProcessExit(LosTaskCB *runTask, INT32 status);
|
||||
extern UINT32 OsUserInitProcess(VOID);
|
||||
extern VOID OsTaskSchedQueueDequeue(LosTaskCB *taskCB, UINT16 status);
|
||||
extern VOID OsTaskSchedQueueEnqueue(LosTaskCB *taskCB, UINT16 status);
|
||||
extern INT32 OsClone(UINT32 flags, UINTPTR sp, UINT32 size);
|
||||
extern UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR *name,
|
||||
LosVmSpace *oldAspace, UINTPTR oldFiles);
|
||||
extern VOID OsExecProcessVmSpaceRestore(LosVmSpace *oldSpace);
|
||||
extern LosVmSpace *OsExecProcessVmSpaceReplace(LosVmSpace *newSpace, UINTPTR stackBase, INT32 randomDevFD);
|
||||
extern UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR *name, LosVmSpace *oldAspace, UINTPTR oldFiles);
|
||||
extern UINT32 OsExecStart(const TSK_ENTRY_FUNC entry, UINTPTR sp, UINTPTR mapBase, UINT32 mapSize);
|
||||
extern UINT32 OsSetProcessName(LosProcessCB *processCB, const CHAR *name);
|
||||
extern INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 prio, UINT16 policy);
|
||||
@@ -497,6 +488,9 @@ extern UINTPTR OsGetSigHandler(VOID);
|
||||
extern VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID);
|
||||
extern INT32 OsSendSignalToProcessGroup(INT32 pid, siginfo_t *info, INT32 permission);
|
||||
extern INT32 OsSendSignalToAllProcess(siginfo_t *info, INT32 permission);
|
||||
extern UINT32 OsProcessAddNewTask(UINT32 pid, LosTaskCB *taskCB);
|
||||
extern VOID OsDeleteTaskFromProcess(LosTaskCB *taskCB);
|
||||
extern VOID OsProcessThreadGroupDestroy(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -32,10 +32,22 @@
|
||||
#ifndef _LOS_SCHED_PRI_H
|
||||
#define _LOS_SCHED_PRI_H
|
||||
|
||||
#include "los_task_pri.h"
|
||||
#include "los_sortlink_pri.h"
|
||||
#include "los_sys_pri.h"
|
||||
#include "los_hwi.h"
|
||||
#include "hal_timer.h"
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#include "los_stat_pri.h"
|
||||
#endif
|
||||
#include "los_stackinfo_pri.h"
|
||||
#include "los_futex_pri.h"
|
||||
#include "los_signal.h"
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
#include "los_cpup_pri.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||
#include "hm_liteipc.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -53,6 +65,11 @@ extern UINT32 g_taskScheduled;
|
||||
|
||||
typedef BOOL (*SCHED_TL_FIND_FUNC)(UINTPTR, UINTPTR);
|
||||
|
||||
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
|
||||
{
|
||||
return HalClockGetCycles();
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
INT_NO_RESCH = 0x0, /* no needs to schedule */
|
||||
INT_PEND_RESCH = 0x1, /* pending schedule flag */
|
||||
@@ -243,9 +260,212 @@ VOID OsSchedRunQueSwtmrInit(UINT32 swtmrTaskID, UINT32 swtmrQueue);
|
||||
VOID OsSchedRunQueInit(VOID);
|
||||
BOOL OsSchedSwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg);
|
||||
|
||||
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Define a usable task priority.
|
||||
*
|
||||
* Highest task priority.
|
||||
*/
|
||||
#define OS_TASK_PRIORITY_HIGHEST 0
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Define a usable task priority.
|
||||
*
|
||||
* Lowest task priority.
|
||||
*/
|
||||
#define OS_TASK_PRIORITY_LOWEST 31
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is init.
|
||||
*/
|
||||
#define OS_TASK_STATUS_INIT 0x0001U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is ready.
|
||||
*/
|
||||
#define OS_TASK_STATUS_READY 0x0002U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is running.
|
||||
*/
|
||||
#define OS_TASK_STATUS_RUNNING 0x0004U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is suspended.
|
||||
*/
|
||||
#define OS_TASK_STATUS_SUSPENDED 0x0008U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is blocked.
|
||||
*/
|
||||
#define OS_TASK_STATUS_PENDING 0x0010U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is delayed.
|
||||
*/
|
||||
#define OS_TASK_STATUS_DELAY 0x0020U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The time for waiting for an event to occur expires.
|
||||
*/
|
||||
#define OS_TASK_STATUS_TIMEOUT 0x0040U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is pend for a period of time.
|
||||
*/
|
||||
#define OS_TASK_STATUS_PEND_TIME 0x0080U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is exit.
|
||||
*/
|
||||
#define OS_TASK_STATUS_EXIT 0x0100U
|
||||
|
||||
#define OS_TCB_NAME_LEN 32
|
||||
|
||||
typedef struct {
|
||||
VOID *stackPointer; /**< Task stack pointer */
|
||||
UINT16 taskStatus; /**< Task status */
|
||||
|
||||
/* The scheduling */
|
||||
UINT16 basePrio;
|
||||
UINT16 priority; /**< Task priority */
|
||||
UINT16 policy;
|
||||
UINT64 startTime; /**< The start time of each phase of task */
|
||||
UINT64 irqStartTime; /**< Interrupt start time */
|
||||
UINT32 irqUsedTime; /**< Interrupt consumption time */
|
||||
UINT32 initTimeSlice; /**< Task init time slice */
|
||||
INT32 timeSlice; /**< Task remaining time slice */
|
||||
UINT32 waitTimes; /**< Task delay time, tick number */
|
||||
SortLinkList sortList; /**< Task sortlink node */
|
||||
|
||||
UINT32 stackSize; /**< Task stack size */
|
||||
UINTPTR topOfStack; /**< Task stack top */
|
||||
UINT32 taskID; /**< Task ID */
|
||||
TSK_ENTRY_FUNC taskEntry; /**< Task entrance function */
|
||||
VOID *joinRetval; /**< pthread adaption */
|
||||
VOID *taskMux; /**< Task-held mutex */
|
||||
VOID *taskEvent; /**< Task-held event */
|
||||
UINTPTR args[4]; /**< Parameter, of which the maximum number is 4 */
|
||||
CHAR taskName[OS_TCB_NAME_LEN]; /**< Task name */
|
||||
LOS_DL_LIST pendList; /**< Task pend node */
|
||||
LOS_DL_LIST threadList; /**< thread list */
|
||||
UINT32 eventMask; /**< Event mask */
|
||||
UINT32 eventMode; /**< Event mode */
|
||||
UINT32 priBitMap; /**< BitMap for recording the change of task priority,
|
||||
the priority can not be greater than 31 */
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
OsCpupBase taskCpup; /**< task cpu usage */
|
||||
#endif
|
||||
INT32 errorNo; /**< Error Num */
|
||||
UINT32 signal; /**< Task signal */
|
||||
sig_cb sig;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT16 currCpu; /**< CPU core number of this task is running on */
|
||||
UINT16 lastCpu; /**< CPU core number of this task is running on last time */
|
||||
UINT16 cpuAffiMask; /**< CPU affinity mask, support up to 16 cores */
|
||||
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
||||
UINT32 syncSignal; /**< Synchronization for signal handling */
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
|
||||
LockDep lockDep;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
SchedStat schedStat; /**< Schedule statistics */
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
UINTPTR archMmu;
|
||||
UINTPTR userArea;
|
||||
UINTPTR userMapBase;
|
||||
UINT32 userMapSize; /**< user thread stack size ,real size : userMapSize + USER_STACK_MIN_SIZE */
|
||||
FutexNode futex;
|
||||
#endif
|
||||
UINT32 processID; /**< Which belong process */
|
||||
LOS_DL_LIST joinList; /**< join list */
|
||||
LOS_DL_LIST lockList; /**< Hold the lock list */
|
||||
UINTPTR waitID; /**< Wait for the PID or GID of the child process */
|
||||
UINT16 waitFlag; /**< The type of child process that is waiting, belonging to a group or parent,
|
||||
a specific child process, or any child process */
|
||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||
IpcTaskInfo *ipcTaskInfo;
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_PERF
|
||||
UINTPTR pc;
|
||||
UINTPTR fp;
|
||||
#endif
|
||||
} LosTaskCB;
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsRunning(const LosTaskCB *taskCB)
|
||||
{
|
||||
return HalClockGetCycles();
|
||||
return ((taskCB->taskStatus & OS_TASK_STATUS_RUNNING) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsReady(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & OS_TASK_STATUS_READY) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsInactive(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & (OS_TASK_STATUS_INIT | OS_TASK_STATUS_EXIT)) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsPending(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & OS_TASK_STATUS_PENDING) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsSuspended(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & OS_TASK_STATUS_SUSPENDED) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsBlocked(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & (OS_TASK_STATUS_SUSPENDED | OS_TASK_STATUS_PENDING | OS_TASK_STATUS_DELAY)) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE LosTaskCB *OsCurrTaskGet(VOID)
|
||||
{
|
||||
return (LosTaskCB *)ArchCurrTaskGet();
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCurrTaskSet(LosTaskCB *task)
|
||||
{
|
||||
ArchCurrTaskSet(task);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCurrUserTaskSet(UINTPTR thread)
|
||||
{
|
||||
ArchCurrUserTaskSet(thread);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedIrqUpdateUsedTime(VOID)
|
||||
|
||||
@@ -92,8 +92,8 @@ STATIC INLINE UINT32 OsGetSortLinkNodeNum(SortLinkAttribute *head)
|
||||
VOID OsSortLinkInit(SortLinkAttribute *sortLinkHeader);
|
||||
VOID OsAdd2SortLink(SortLinkAttribute *head, SortLinkList *node, UINT64 responseTime, UINT16 idleCpu);
|
||||
VOID OsDeleteFromSortLink(SortLinkAttribute *head, SortLinkList *node);
|
||||
UINT32 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *targetSortList);
|
||||
UINT32 OsSortLinkGetNextExpireTime(UINT64 currTime, const SortLinkAttribute *sortLinkHeader);
|
||||
UINT64 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *targetSortList);
|
||||
UINT64 OsSortLinkGetNextExpireTime(UINT64 currTime, const SortLinkAttribute *sortLinkHeader);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -33,20 +33,8 @@
|
||||
#define _LOS_TASK_PRI_H
|
||||
|
||||
#include "los_task.h"
|
||||
#include "los_sortlink_pri.h"
|
||||
#include "los_spinlock.h"
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#include "los_stat_pri.h"
|
||||
#endif
|
||||
#include "los_stackinfo_pri.h"
|
||||
#include "los_futex_pri.h"
|
||||
#include "los_signal.h"
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
#include "los_cpup_pri.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||
#include "hm_liteipc.h"
|
||||
#endif
|
||||
#include "los_sched_pri.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@@ -79,97 +67,6 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||
*/
|
||||
#define OS_TASK_ERRORID 0xFFFFFFFF
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Define a usable task priority.
|
||||
*
|
||||
* Highest task priority.
|
||||
*/
|
||||
#define OS_TASK_PRIORITY_HIGHEST 0
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Define a usable task priority.
|
||||
*
|
||||
* Lowest task priority.
|
||||
*/
|
||||
#define OS_TASK_PRIORITY_LOWEST 31
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is init.
|
||||
*/
|
||||
#define OS_TASK_STATUS_INIT 0x0001U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is ready.
|
||||
*/
|
||||
#define OS_TASK_STATUS_READY 0x0002U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is running.
|
||||
*/
|
||||
#define OS_TASK_STATUS_RUNNING 0x0004U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is suspended.
|
||||
*/
|
||||
#define OS_TASK_STATUS_SUSPENDED 0x0008U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is blocked.
|
||||
*/
|
||||
#define OS_TASK_STATUS_PENDING 0x0010U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is delayed.
|
||||
*/
|
||||
#define OS_TASK_STATUS_DELAY 0x0020U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The time for waiting for an event to occur expires.
|
||||
*/
|
||||
#define OS_TASK_STATUS_TIMEOUT 0x0040U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is pend for a period of time.
|
||||
*/
|
||||
#define OS_TASK_STATUS_PEND_TIME 0x0080U
|
||||
|
||||
#define OS_TASK_STATUS_BLOCKED (OS_TASK_STATUS_INIT | OS_TASK_STATUS_PENDING | \
|
||||
OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND_TIME)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is exit.
|
||||
*/
|
||||
#define OS_TASK_STATUS_EXIT 0x0100U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
@@ -186,6 +83,14 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||
*/
|
||||
#define OS_TASK_FLAG_PTHREAD_JOIN 0x0400U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is user mode task.
|
||||
*/
|
||||
#define OS_TASK_FLAG_USER_MODE 0x0800U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task property.
|
||||
@@ -306,76 +211,6 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||
#define OS_RESOURCE_EVENT_MASK 0xFF
|
||||
#define OS_RESOURCE_EVENT_OOM 0x02
|
||||
#define OS_RESOURCE_EVENT_FREE 0x04
|
||||
#define OS_TCB_NAME_LEN 32
|
||||
|
||||
typedef struct {
|
||||
VOID *stackPointer; /**< Task stack pointer */
|
||||
UINT16 taskStatus; /**< Task status */
|
||||
|
||||
/* The scheduling */
|
||||
UINT16 priority; /**< Task priority */
|
||||
UINT16 policy;
|
||||
UINT64 startTime; /**< The start time of each phase of task */
|
||||
UINT64 irqStartTime; /**< Interrupt start time */
|
||||
UINT32 irqUsedTime; /**< Interrupt consumption time */
|
||||
UINT32 initTimeSlice; /**< Task init time slice */
|
||||
INT32 timeSlice; /**< Task remaining time slice */
|
||||
UINT32 waitTimes; /**< Task delay time, tick number */
|
||||
SortLinkList sortList; /**< Task sortlink node */
|
||||
|
||||
UINT32 stackSize; /**< Task stack size */
|
||||
UINTPTR topOfStack; /**< Task stack top */
|
||||
UINT32 taskID; /**< Task ID */
|
||||
TSK_ENTRY_FUNC taskEntry; /**< Task entrance function */
|
||||
VOID *joinRetval; /**< pthread adaption */
|
||||
VOID *taskMux; /**< Task-held mutex */
|
||||
VOID *taskEvent; /**< Task-held event */
|
||||
UINTPTR args[4]; /**< Parameter, of which the maximum number is 4 */
|
||||
CHAR taskName[OS_TCB_NAME_LEN]; /**< Task name */
|
||||
LOS_DL_LIST pendList; /**< Task pend node */
|
||||
LOS_DL_LIST threadList; /**< thread list */
|
||||
UINT32 eventMask; /**< Event mask */
|
||||
UINT32 eventMode; /**< Event mode */
|
||||
UINT32 priBitMap; /**< BitMap for recording the change of task priority,
|
||||
the priority can not be greater than 31 */
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
OsCpupBase taskCpup; /**< task cpu usage */
|
||||
#endif
|
||||
INT32 errorNo; /**< Error Num */
|
||||
UINT32 signal; /**< Task signal */
|
||||
sig_cb sig;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT16 currCpu; /**< CPU core number of this task is running on */
|
||||
UINT16 lastCpu; /**< CPU core number of this task is running on last time */
|
||||
UINT16 cpuAffiMask; /**< CPU affinity mask, support up to 16 cores */
|
||||
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
||||
UINT32 syncSignal; /**< Synchronization for signal handling */
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
|
||||
LockDep lockDep;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
SchedStat schedStat; /**< Schedule statistics */
|
||||
#endif
|
||||
UINTPTR userArea;
|
||||
UINTPTR userMapBase;
|
||||
UINT32 userMapSize; /**< user thread stack size ,real size : userMapSize + USER_STACK_MIN_SIZE */
|
||||
UINT32 processID; /**< Which belong process */
|
||||
FutexNode futex;
|
||||
LOS_DL_LIST joinList; /**< join list */
|
||||
LOS_DL_LIST lockList; /**< Hold the lock list */
|
||||
UINTPTR waitID; /**< Wait for the PID or GID of the child process */
|
||||
UINT16 waitFlag; /**< The type of child process that is waiting, belonging to a group or parent,
|
||||
a specific child process, or any child process */
|
||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||
IpcTaskInfo *ipcTaskInfo;
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_PERF
|
||||
UINTPTR pc;
|
||||
UINTPTR fp;
|
||||
#endif
|
||||
} LosTaskCB;
|
||||
|
||||
typedef struct {
|
||||
LosTaskCB *runTask;
|
||||
@@ -416,21 +251,6 @@ typedef struct {
|
||||
UINT16 timeout; /**< Expiration duration */
|
||||
} OsTaskRobin;
|
||||
|
||||
STATIC INLINE LosTaskCB *OsCurrTaskGet(VOID)
|
||||
{
|
||||
return (LosTaskCB *)ArchCurrTaskGet();
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCurrTaskSet(LosTaskCB *task)
|
||||
{
|
||||
ArchCurrTaskSet(task);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCurrUserTaskSet(UINTPTR thread)
|
||||
{
|
||||
ArchCurrUserTaskSet(thread);
|
||||
}
|
||||
|
||||
STATIC INLINE LosTaskCB *OsGetTaskCB(UINT32 taskID)
|
||||
{
|
||||
return OS_TCB_FROM_TID(taskID);
|
||||
@@ -438,47 +258,17 @@ STATIC INLINE LosTaskCB *OsGetTaskCB(UINT32 taskID)
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsUnused(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsRunning(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsInactive(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & (OS_TASK_STATUS_UNUSED | OS_TASK_STATUS_INIT | OS_TASK_STATUS_EXIT)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsPending(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_PENDING) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsKilled(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_FLAG_EXIT_KILL) {
|
||||
return TRUE;
|
||||
}
|
||||
return ((taskCB->taskStatus & OS_TASK_FLAG_EXIT_KILL) != 0);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
STATIC INLINE BOOL OsTaskIsUserMode(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & OS_TASK_FLAG_USER_MODE) != 0);
|
||||
}
|
||||
|
||||
#define OS_TID_CHECK_INVALID(taskID) ((UINT32)(taskID) >= g_taskMaxNum)
|
||||
@@ -529,21 +319,18 @@ extern VOID OsSetMainTask(VOID);
|
||||
extern UINT32 OsGetIdleTaskId(VOID);
|
||||
extern VOID OsTaskEntry(UINT32 taskID);
|
||||
extern VOID OsTaskProcSignal(VOID);
|
||||
extern UINT32 OsTaskDeleteUnsafe(LosTaskCB *taskCB, UINT32 status, UINT32 intSave);
|
||||
extern VOID OsTaskResourcesToFree(LosTaskCB *taskCB);
|
||||
extern VOID OsRunTaskToDelete(LosTaskCB *taskCB);
|
||||
extern UINT32 OsCreateUserTask(UINT32 processID, TSK_INIT_PARAM_S *initParam);
|
||||
extern INT32 OsSetTaskName(LosTaskCB *taskCB, const CHAR *name, BOOL setPName);
|
||||
extern VOID OsTaskCBRecycleToFree(VOID);
|
||||
extern VOID OsTaskExitGroup(UINT32 status);
|
||||
extern VOID OsTaskToExit(LosTaskCB *taskCB, UINT32 status);
|
||||
extern VOID OsExecDestroyTaskGroup(VOID);
|
||||
extern VOID OsRunningTaskToExit(LosTaskCB *runTask, UINT32 status);
|
||||
extern UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB);
|
||||
extern UINT32 OsUserProcessOperatePermissionsCheck(LosTaskCB *taskCB, UINT32 processID);
|
||||
extern INT32 OsTcbDispatch(LosTaskCB *stcb, siginfo_t *info);
|
||||
extern VOID OsWriteResourceEvent(UINT32 events);
|
||||
extern VOID OsWriteResourceEventUnsafe(UINT32 events);
|
||||
extern UINT32 OsResourceFreeTaskCreate(VOID);
|
||||
extern VOID OsTaskInsertToRecycleList(LosTaskCB *taskCB);
|
||||
extern VOID OsInactiveTaskDelete(LosTaskCB *taskCB);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user