39#ifdef LOSCFG_KERNEL_CPUP
44#ifdef LOSCFG_BASE_CORE_TSK_MONITOR
54 BOOL isTimeSlice = FALSE;
67 if ((nextExpireTime > taskEndTime) && ((nextExpireTime - taskEndTime) > OS_SCHED_MINI_PERIOD)) {
68 nextExpireTime = taskEndTime;
73 ((rq->
responseTime - nextExpireTime) < OS_TICK_RESPONSE_PRECISION)) {
84 UINT64 nextResponseTime = nextExpireTime - currTime;
91 if (!OS_SCHEDULER_ACTIVE || OS_INT_ACTIVE) {
97 SCHEDULER_LOCK(intSave);
99 SCHEDULER_UNLOCK(intSave);
105#ifndef LOSCFG_SCHED_DEBUG
111 if (tempStatus & (OS_TASK_STATUS_PENDING | OS_TASK_STATUS_DELAY)) {
112 taskCB->
taskStatus &= ~(OS_TASK_STATUS_PENDING | OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY);
113 if (tempStatus & OS_TASK_STATUS_PENDING) {
120 if (!(tempStatus & OS_TASK_STATUS_SUSPENDED)) {
121#ifdef LOSCFG_SCHED_DEBUG
135 BOOL needSched = FALSE;
200 for (
UINT16 index = 0; index < LOSCFG_KERNEL_CORE_NUM; index++) {
215 for (
UINT16 cpuId = 0; cpuId < LOSCFG_KERNEL_CORE_NUM; cpuId++) {
219#ifdef LOSCFG_SCHED_TICK_DEBUG
238 if (rp1->
policy == rp2->policy) {
242 if (rp1->
policy == LOS_SCHED_IDLE) {
244 }
else if (rp2->policy == LOS_SCHED_IDLE) {
276 PRINT_ERR(
"Invalid process-level scheduling policy, %u\n", policy);
286 if (newTask == NULL) {
299 PRINTK(
"cpu %d entering scheduler\n", cpuid);
301 SCHEDULER_LOCK(intSave);
307 newTask->
taskStatus |= OS_TASK_STATUS_RUNNING;
309#ifdef LOSCFG_KERNEL_SMP
324 OS_SCHEDULER_SET(cpuid);
332#ifdef LOSCFG_KERNEL_SMP
343#ifdef LOSCFG_BASE_CORE_TSK_MONITOR
346 if (!OS_STACK_MAGIC_CHECK(runTask->
topOfStack)) {
352 LOS_Panic(
"HIGHEST task ID: %s:%u SP error! StackPointer: %p TopOfStack: %p\n",
360#ifdef LOSCFG_BASE_CORE_TSK_MONITOR
363 OsHookCall(LOS_HOOK_TYPE_TASK_SWITCHEDIN, newTask, runTask);
370 runTask->
taskStatus &= ~OS_TASK_STATUS_RUNNING;
371 newTask->
taskStatus |= OS_TASK_STATUS_RUNNING;
373#ifdef LOSCFG_KERNEL_SMP
375 runTask->
currCpu = OS_TASK_INVALID_CPUID;
380#ifdef LOSCFG_KERNEL_VM
386#ifdef LOSCFG_KERNEL_CPUP
390#ifdef LOSCFG_SCHED_DEBUG
393 if (runTask->
taskStatus & OS_TASK_STATUS_READY) {
402 if (runTask->
taskStatus & (OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY)) {
410#ifdef LOSCFG_SCHED_DEBUG
435 if (runTask != newTask) {
453#ifdef LOSCFG_KERNEL_SMP
462 if (runTask == newTask) {
489 SCHEDULER_LOCK(intSave);
499 SCHEDULER_UNLOCK(intSave);
506 LOS_DL_LIST_FOR_EACH_ENTRY(pendedTask, lockList,
LosTaskCB, pendList) {
510 }
else if (ret > 0) {
525 LosTaskCB *pendedTask1 = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(lockList));
531 LosTaskCB *pendedTask2 = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_LAST(lockList));
NORETURN VOID LOS_Panic(const CHAR *fmt,...)
Kernel panic function.
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelete(LOS_DL_LIST *node)
LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
Identify whether a specified doubly linked list is empty. | 判断链表是否为空
VOID LOS_Schedule(VOID)
Trigger active task scheduling.
UINT64 HalClockTickTimerReload(UINT64 cycles)
https://blog.csdn.net/qq_38410730/article/details/81036768
VOID LOS_ArchMmuContextSwitch(LosArchMmu *archMmu)
LOS_ArchMmuContextSwitch 切换MMU上下文
VOID OsCpupCycleEndStart(UINT32 runTaskID, UINT32 newTaskID)
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
LITE_OS_SEC_TEXT_INIT VOID OsTickStart(VOID)
启动节拍
VOID LOS_MpSchedule(UINT32 target)
STATIC VOID TaskStackCheck(LosTaskCB *runTask, LosTaskCB *newTask)
VOID OsSchedIrqEndCheckNeedSched(VOID)
VOID OsSchedRunqueueInit(VOID)
VOID OsSchedExpireTimeUpdate(VOID)
STATIC INLINE VOID SchedSwitchCheck(LosTaskCB *runTask, LosTaskCB *newTask)
STATIC INLINE LOS_DL_LIST * SchedLockPendFindPosSub(const LosTaskCB *runTask, const LOS_DL_LIST *lockList)
VOID OsSchedRunqueueIdleInit(UINT32 idleTaskID)
STATIC INLINE VOID SchedTimeoutTaskWake(SchedRunqueue *rq, UINT64 currTime, LosTaskCB *taskCB, BOOL *needSched)
STATIC INLINE BOOL SchedTimeoutQueueScan(SchedRunqueue *rq)
STATIC INLINE VOID SchedNextExpireTimeSet(UINT32 responseID, UINT64 taskEndTime, UINT32 oldResponseID)
LOS_DL_LIST * OsSchedLockPendFindPos(const LosTaskCB *runTask, LOS_DL_LIST *lockList)
INT32 OsSchedParamCompare(const LosTaskCB *task1, const LosTaskCB *task2)
STATIC LosTaskCB * TopTaskGet(SchedRunqueue *rq)
UINT32 OsSchedParamInit(LosTaskCB *taskCB, UINT16 policy, const SchedParam *parentParam, const TSK_INIT_PARAM_S *param)
VOID OsSchedProcessDefaultSchedParamGet(UINT16 policy, SchedParam *param)
VOID OsSchedToUserReleaseLock(VOID)
VOID OsSchedResponseTimeReset(UINT64 responseTime)
STATIC VOID SchedTaskSwitch(SchedRunqueue *rq, LosTaskCB *runTask, LosTaskCB *newTask)
SchedRunqueue g_schedRunqueue[LOSCFG_KERNEL_CORE_NUM]
VOID OsSchedResched(VOID)
STATIC INLINE VOID OsSchedUnlock(VOID)
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
STATIC INLINE LosTaskCB * OsCurrTaskGet(VOID)
STATIC INLINE SchedRunqueue * OsSchedRunqueueByID(UINT16 id)
STATIC INLINE BOOL OsPreemptable(VOID)
STATIC INLINE SchedRunqueue * OsSchedRunqueue(VOID)
STATIC INLINE VOID OsSchedTimeoutQueueAdd(LosTaskCB *taskCB, UINT64 responseTime)
STATIC INLINE VOID OsSchedRunqueuePendingSet(VOID)
VOID IdleTaskSchedParamInit(LosTaskCB *taskCB)
VOID HPFSchedPolicyInit(SchedRunqueue *rq)
STATIC INLINE LosTaskCB * HPFRunqueueTopTaskGet(HPFRunqueue *rq)
STATIC INLINE VOID OsCurrTaskSet(LosTaskCB *task)
注意任务地址由硬件保存,见于 CP15 | TPIDRPRW
VOID HPFProcessDefaultSchedParamGet(SchedParam *param)
VOID HPFTaskSchedParamInit(LosTaskCB *taskCB, UINT16 policy, const SchedParam *parentParam, const TSK_INIT_PARAM_S *param)
VOID OsSortLinkInit(SortLinkAttribute *sortLinkHeader)
排序链表初始化
STATIC INLINE UINT64 OsGetSortLinkNextExpireTime(SortLinkAttribute *sortHeader, UINT64 startTime, UINT32 tickPrecision)
STATIC INLINE VOID OsDeleteNodeSortLink(SortLinkAttribute *sortLinkHeader, SortLinkList *sortList)
BOOL LOS_SpinHeld(const SPIN_LOCK_S *lock)
VOID LOS_SpinLock(SPIN_LOCK_S *lock)
VOID LOS_SpinUnlock(SPIN_LOCK_S *lock)
VOID ArchSpinUnlock(size_t *lock)
UINT32 OsSchedDebugInit(VOID)
VOID OsSwtmrResponseTimeReset(UINT64 startTime)
VOID OsTaskContextLoad(LosTaskCB *newTask)
STATIC INLINE VOID OsTaskWakeClearPendMask(LosTaskCB *resumeTask)
清除事件阻塞掩码,即任务不再等待任何事件.
VOID OsTaskSchedule(LosTaskCB *, LosTaskCB *)
内存管理单元(英语:memory management unit,缩写为MMU),有时称作分页内存管理单元(英语:paged memory management unit,缩写为PMMU)。
struct LOS_DL_LIST * pstNext
INT32(* schedParamCompare)(const SchedPolicy *sp1, const SchedPolicy *sp2)
比较调度参数
VOID(* enqueue)(SchedRunqueue *rq, LosTaskCB *taskCB)
入队列
UINT64(* deadlineGet)(const LosTaskCB *taskCB)
获取最后期限
VOID(* timeSliceUpdate)(SchedRunqueue *rq, LosTaskCB *taskCB, UINT64 currTime)
更新时间片
VOID(* start)(SchedRunqueue *rq, LosTaskCB *taskCB)
开始执行任务
SortLinkAttribute timeoutQueue
HPFRunqueue * hpfRunqueue
LOS_DL_LIST sortLink
排序链表,上面挂的任务/软件定时器
UINT64 responseTime
响应时间,这里提取了最近需要触发的定时器/任务的时间,见于 OsAddNode2SortLink 的实现
CHAR taskName[OS_TCB_NAME_LEN]