更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_priority.c 文件参考

浏览源代码.

函数

STATIC VOID HPFDequeue (SchedRunqueue *rq, LosTaskCB *taskCB)
 
STATIC VOID HPFEnqueue (SchedRunqueue *rq, LosTaskCB *taskCB)
 
STATIC UINT32 HPFWait (LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 ticks)
 
STATIC VOID HPFWake (LosTaskCB *resumedTask)
 
STATIC BOOL HPFSchedParamModify (LosTaskCB *taskCB, const SchedParam *param)
 
STATIC UINT32 HPFSchedParamGet (const LosTaskCB *taskCB, SchedParam *param)
 
STATIC UINT32 HPFDelay (LosTaskCB *runTask, UINT64 waitTime)
 
STATIC VOID HPFYield (LosTaskCB *runTask)
 
STATIC VOID HPFStartToRun (SchedRunqueue *rq, LosTaskCB *taskCB)
 
STATIC VOID HPFExit (LosTaskCB *taskCB)
 
STATIC UINT32 HPFSuspend (LosTaskCB *taskCB)
 
STATIC UINT32 HPFResume (LosTaskCB *taskCB, BOOL *needSched)
 
STATIC UINT64 HPFTimeSliceGet (const LosTaskCB *taskCB)
 
STATIC VOID HPFTimeSliceUpdate (SchedRunqueue *rq, LosTaskCB *taskCB, UINT64 currTime)
 
STATIC INT32 HPFParamCompare (const SchedPolicy *sp1, const SchedPolicy *sp2)
 
STATIC VOID HPFPriorityInheritance (LosTaskCB *owner, const SchedParam *param)
 
STATIC VOID HPFPriorityRestore (LosTaskCB *owner, const LOS_DL_LIST *list, const SchedParam *param)
 恢复任务优先级 更多...
 
STATIC INLINE UINT32 TimeSliceCalculate (HPFRunqueue *rq, UINT16 basePrio, UINT16 priority)
 
STATIC INLINE VOID PriQueHeadInsert (HPFRunqueue *rq, UINT32 basePrio, LOS_DL_LIST *priQue, UINT32 priority)
 
STATIC INLINE VOID PriQueTailInsert (HPFRunqueue *rq, UINT32 basePrio, LOS_DL_LIST *priQue, UINT32 priority)
 
STATIC INLINE VOID PriQueDelete (HPFRunqueue *rq, UINT32 basePrio, LOS_DL_LIST *priQue, UINT32 priority)
 
STATIC INLINE VOID PriQueInsert (HPFRunqueue *rq, LosTaskCB *taskCB)
 
STATIC BOOL BasePriorityModify (SchedRunqueue *rq, LosTaskCB *taskCB, UINT16 priority)
 
VOID HPFTaskSchedParamInit (LosTaskCB *taskCB, UINT16 policy, const SchedParam *parentParam, const TSK_INIT_PARAM_S *param)
 
VOID HPFProcessDefaultSchedParamGet (SchedParam *param)
 
VOID HPFSchedPolicyInit (SchedRunqueue *rq)
 

变量

STATIC HPFRunqueue g_schedHPF
 
const STATIC SchedOps g_priorityOps
 

函数说明

◆ BasePriorityModify()

STATIC BOOL BasePriorityModify ( SchedRunqueue rq,
LosTaskCB taskCB,
UINT16  priority 
)

在文件 los_priority.c343 行定义.

344{
345 LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
346 BOOL needSched = FALSE;
347
348 LOS_DL_LIST_FOR_EACH_ENTRY(taskCB, &processCB->threadSiblingList, LosTaskCB, threadList) {
349 SchedHPF *sched = (SchedHPF *)&taskCB->sp;
350 if (taskCB->taskStatus & OS_TASK_STATUS_READY) {
351 taskCB->ops->dequeue(rq, taskCB);
352 sched->basePrio = priority;
353 taskCB->ops->enqueue(rq, taskCB);
354 } else {
355 sched->basePrio = priority;
356 }
357 if (taskCB->taskStatus & (OS_TASK_STATUS_READY | OS_TASK_STATUS_RUNNING)) {
358 needSched = TRUE;
359 }
360 }
361
362 return needSched;
363}
size_t BOOL
Definition: los_typedef.h:88
LOS_DL_LIST threadSiblingList
UINT16 basePrio
起始优先级
VOID(* enqueue)(SchedRunqueue *rq, LosTaskCB *taskCB)
入队列
VOID(* dequeue)(SchedRunqueue *rq, LosTaskCB *taskCB)
出队列
SchedPolicy sp
UINT32 processID
const SchedOps * ops
UINT16 taskStatus
if(tv==NULL)
Definition: time.c:430
函数调用图:
这是这个函数的调用关系图:

◆ HPFDelay()

STATIC UINT32 HPFDelay ( LosTaskCB runTask,
UINT64  waitTime 
)

在文件 los_priority.c294 行定义.

295{
296 runTask->taskStatus |= OS_TASK_STATUS_DELAY;
297 runTask->waitTime = waitTime;
298
300 return LOS_OK;
301}
VOID OsSchedResched(VOID)
Definition: los_sched.c:449
UINT64 waitTime
函数调用图:

◆ HPFDequeue()

STATIC VOID HPFDequeue ( SchedRunqueue rq,
LosTaskCB taskCB 
)

在文件 los_priority.c254 行定义.

255{
256 SchedHPF *sched = (SchedHPF *)&taskCB->sp;
257
258 if (taskCB->taskStatus & OS_TASK_STATUS_READY) {//是否有就绪状态
259 PriQueDelete(rq->hpfRunqueue, sched->basePrio, &taskCB->pendList, sched->priority);
260 taskCB->taskStatus &= ~OS_TASK_STATUS_READY;//更新成非就绪状态
261 }
262}
STATIC INLINE VOID PriQueDelete(HPFRunqueue *rq, UINT32 basePrio, LOS_DL_LIST *priQue, UINT32 priority)
Definition: los_priority.c:187
UINT16 priority
当前优先级
HPFRunqueue * hpfRunqueue
LOS_DL_LIST pendList
函数调用图:
这是这个函数的调用关系图:

◆ HPFEnqueue()

STATIC VOID HPFEnqueue ( SchedRunqueue rq,
LosTaskCB taskCB 
)

在文件 los_priority.c244 行定义.

245{
246#ifdef LOSCFG_SCHED_DEBUG
247 if (!(taskCB->taskStatus & OS_TASK_STATUS_RUNNING)) {
249 }
250#endif
251 PriQueInsert(rq->hpfRunqueue, taskCB);
252}
STATIC INLINE VOID PriQueInsert(HPFRunqueue *rq, LosTaskCB *taskCB)
Definition: los_priority.c:204
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
Definition: los_sched_pri.h:75
UINT64 startTime
函数调用图:
这是这个函数的调用关系图:

◆ HPFExit()

STATIC VOID HPFExit ( LosTaskCB taskCB)

在文件 los_priority.c269 行定义.

270{
271 if (taskCB->taskStatus & OS_TASK_STATUS_READY) {
272 HPFDequeue(OsSchedRunqueue(), taskCB);
273 } else if (taskCB->taskStatus & OS_TASK_STATUS_PENDING) {
274 LOS_ListDelete(&taskCB->pendList);
275 taskCB->taskStatus &= ~OS_TASK_STATUS_PENDING;
276 }
277
278 if (taskCB->taskStatus & (OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND_TIME)) {
280 taskCB->taskStatus &= ~(OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND_TIME);
281 }
282}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelete(LOS_DL_LIST *node)
Definition: los_list.h:292
STATIC VOID HPFDequeue(SchedRunqueue *rq, LosTaskCB *taskCB)
Definition: los_priority.c:254
STATIC INLINE SchedRunqueue * OsSchedRunqueue(VOID)
STATIC INLINE VOID OsSchedTimeoutQueueDelete(LosTaskCB *taskCB)
函数调用图:

◆ HPFParamCompare()

STATIC INT32 HPFParamCompare ( const SchedPolicy sp1,
const SchedPolicy sp2 
)

在文件 los_priority.c442 行定义.

443{
444 SchedHPF *param1 = (SchedHPF *)sp1;
445 SchedHPF *param2 = (SchedHPF *)sp2;
446
447 if (param1->basePrio != param2->basePrio) {
448 return (param1->basePrio - param2->basePrio);
449 }
450
451 return (param1->priority - param2->priority);
452}

◆ HPFPriorityInheritance()

STATIC VOID HPFPriorityInheritance ( LosTaskCB owner,
const SchedParam param 
)

在文件 los_priority.c454 行定义.

455{
456 SchedHPF *sp = (SchedHPF *)&owner->sp;
457
458 if ((param->policy != LOS_SCHED_RR) && (param->policy != LOS_SCHED_FIFO)) {
459 return;
460 }
461
462 if (sp->priority <= param->priority) {
463 return;
464 }
465
466 LOS_BitmapSet(&sp->priBitmap, sp->priority);
467 sp->priority = param->priority;
468}
macro EXC_SP_SET reg1 mrc 获取CPU信息 and mov mul reg0 计算当前CPU栈的偏移位置 ldr reg1 相减得到栈顶 mov sp
Definition: asm.h:57
VOID LOS_BitmapSet(UINT32 *bitmap, UINT16 pos)
对状态字的某一标志位进行置1操作
Definition: los_bitmap.c:60
UINT16 policy
UINT16 priority
函数调用图:

◆ HPFPriorityRestore()

STATIC VOID HPFPriorityRestore ( LosTaskCB owner,
const LOS_DL_LIST list,
const SchedParam param 
)

恢复任务优先级

在文件 los_priority.c470 行定义.

471{
472 UINT16 priority;
473 LosTaskCB *pendedTask = NULL;
474
475 if ((param->policy != LOS_SCHED_RR) && (param->policy != LOS_SCHED_FIFO)) {
476 return;
477 }
478
479 SchedHPF *sp = (SchedHPF *)&owner->sp;
480 if (sp->priority < param->priority) {
481 if (LOS_HighBitGet(sp->priBitmap) != param->priority) {
482 LOS_BitmapClr(&sp->priBitmap, param->priority);
483 }
484 return;
485 }
486
487 if (sp->priBitmap == 0) {
488 return;
489 }
490
491 if ((list != NULL) && !LOS_ListEmpty((LOS_DL_LIST *)list)) {
492 priority = LOS_HighBitGet(sp->priBitmap);//获取在历史调度中最高优先级
493 LOS_DL_LIST_FOR_EACH_ENTRY(pendedTask, list, LosTaskCB, pendList) {//遍历链表
494 SchedHPF *pendSp = (SchedHPF *)&pendedTask->sp;
495 if ((pendedTask->ops == owner->ops) && (priority != pendSp->priority)) {
496 LOS_BitmapClr(&sp->priBitmap, pendSp->priority);
497 }
498 }
499 }
500
501 priority = LOS_LowBitGet(sp->priBitmap);
502 if (priority != LOS_INVALID_BIT_INDEX) {
503 LOS_BitmapClr(&sp->priBitmap, priority);
504 sp->priority = priority;
505 }
506}
VOID LOS_BitmapClr(UINT32 *bitmap, UINT16 pos)
对状态字的某一标志位进行清0操作
Definition: los_bitmap.c:69
UINT16 LOS_LowBitGet(UINT32 bitmap)
获取参数位图中最低位为1的索引位, 例如: 00110110 返回 1
Definition: los_bitmap.c:97
UINT16 LOS_HighBitGet(UINT32 bitmap)
获取参数位图中最高位为1的索引位 例如: 00110110 返回 5
Definition: los_bitmap.c:88
LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
Identify whether a specified doubly linked list is empty. | 判断链表是否为空
Definition: los_list.h:321
unsigned short UINT16
Definition: los_typedef.h:56
函数调用图:

◆ HPFProcessDefaultSchedParamGet()

VOID HPFProcessDefaultSchedParamGet ( SchedParam param)

在文件 los_priority.c527 行定义.

528{
529 param->basePrio = OS_USER_PROCESS_PRIORITY_HIGHEST;
530}
UINT16 basePrio
这是这个函数的调用关系图:

◆ HPFResume()

STATIC UINT32 HPFResume ( LosTaskCB taskCB,
BOOL needSched 
)

在文件 los_priority.c427 行定义.

428{
429 *needSched = FALSE;
430
431 SchedTaskUnfreeze(taskCB);
432
433 taskCB->taskStatus &= ~OS_TASK_STATUS_SUSPENDED;
434 if (!OsTaskIsBlocked(taskCB)) {
435 HPFEnqueue(OsSchedRunqueue(), taskCB);
436 *needSched = TRUE;
437 }
438
439 return LOS_OK;
440}
STATIC VOID HPFEnqueue(SchedRunqueue *rq, LosTaskCB *taskCB)
Definition: los_priority.c:244
STATIC INLINE VOID SchedTaskUnfreeze(LosTaskCB *taskCB)
STATIC INLINE BOOL OsTaskIsBlocked(const LosTaskCB *taskCB)
函数调用图:

◆ HPFSchedParamGet()

STATIC UINT32 HPFSchedParamGet ( const LosTaskCB taskCB,
SchedParam param 
)

在文件 los_priority.c401 行定义.

402{
403 SchedHPF *sched = (SchedHPF *)&taskCB->sp;
404 param->policy = sched->policy;
405 param->basePrio = sched->basePrio;
406 param->priority = sched->priority;
407 param->timeSlice = sched->initTimeSlice;
408 return LOS_OK;
409}
UINT16 policy
UINT32 initTimeSlice
初始化时间片
UINT32 timeSlice

◆ HPFSchedParamModify()

STATIC BOOL HPFSchedParamModify ( LosTaskCB taskCB,
const SchedParam param 
)

在文件 los_priority.c365 行定义.

366{
368 BOOL needSched = FALSE;
369 SchedHPF *sched = (SchedHPF *)&taskCB->sp;
370
371 if (sched->policy != param->policy) {
372 sched->policy = param->policy;
373 taskCB->timeSlice = 0;
374 }
375
376 if (sched->basePrio != param->basePrio) {
377 needSched = BasePriorityModify(rq, taskCB, param->basePrio);
378 }
379
380 if (taskCB->taskStatus & OS_TASK_STATUS_READY) {
381 HPFDequeue(rq, taskCB);
382 sched->priority = param->priority;
383 HPFEnqueue(rq, taskCB);
384 return TRUE;
385 }
386
387 sched->priority = param->priority;
388 OsHookCall(LOS_HOOK_TYPE_TASK_PRIMODIFY, taskCB, sched->priority);
389 if (taskCB->taskStatus & OS_TASK_STATUS_INIT) {
390 HPFEnqueue(rq, taskCB);
391 return TRUE;
392 }
393
394 if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
395 return TRUE;
396 }
397
398 return needSched;
399}
STATIC BOOL BasePriorityModify(SchedRunqueue *rq, LosTaskCB *taskCB, UINT16 priority)
Definition: los_priority.c:343
INT32 timeSlice
函数调用图:

◆ HPFSchedPolicyInit()

VOID HPFSchedPolicyInit ( SchedRunqueue rq)

在文件 los_priority.c532 行定义.

533{
534 if (ArchCurrCpuid() > 0) {
535 rq->hpfRunqueue = &g_schedHPF;
536 return;
537 }
538
539 for (UINT16 index = 0; index < OS_PRIORITY_QUEUE_NUM; index++) {
540 HPFQueue *queueList = &g_schedHPF.queueList[index];
541 LOS_DL_LIST *priQue = &queueList->priQueList[0];
542 for (UINT16 prio = 0; prio < OS_PRIORITY_QUEUE_NUM; prio++) {
543 LOS_ListInit(&priQue[prio]);
544 }
545 }
546
547 rq->hpfRunqueue = &g_schedHPF;
548}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
Definition: los_list.h:104
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
Definition: los_hw_cpu.h:168
STATIC HPFRunqueue g_schedHPF
Definition: los_priority.c:48
LOS_DL_LIST priQueList[OS_PRIORITY_QUEUE_NUM]
Definition: los_sched_pri.h:88
HPFQueue queueList[OS_PRIORITY_QUEUE_NUM]
Definition: los_sched_pri.h:94
函数调用图:
这是这个函数的调用关系图:

◆ HPFStartToRun()

STATIC VOID HPFStartToRun ( SchedRunqueue rq,
LosTaskCB taskCB 
)

在文件 los_priority.c264 行定义.

265{
266 HPFDequeue(rq, taskCB);
267}
函数调用图:

◆ HPFSuspend()

STATIC UINT32 HPFSuspend ( LosTaskCB taskCB)

在文件 los_priority.c411 行定义.

412{
413 if (taskCB->taskStatus & OS_TASK_STATUS_READY) {
414 HPFDequeue(OsSchedRunqueue(), taskCB);
415 }
416
417 SchedTaskFreeze(taskCB);
418
419 taskCB->taskStatus |= OS_TASK_STATUS_SUSPENDED;
420 OsHookCall(LOS_HOOK_TYPE_MOVEDTASKTOSUSPENDEDLIST, taskCB);
421 if (taskCB == OsCurrTaskGet()) {
423 }
424 return LOS_OK;
425}
STATIC INLINE LosTaskCB * OsCurrTaskGet(VOID)
STATIC INLINE VOID SchedTaskFreeze(LosTaskCB *taskCB)
函数调用图:

◆ HPFTaskSchedParamInit()

VOID HPFTaskSchedParamInit ( LosTaskCB taskCB,
UINT16  policy,
const SchedParam parentParam,
const TSK_INIT_PARAM_S param 
)

在文件 los_priority.c508 行定义.

511{
512 SchedHPF *sched = (SchedHPF *)&taskCB->sp;
513
514 sched->policy = policy;
515 if (param != NULL) {
516 sched->priority = param->usTaskPrio;
517 } else {
518 sched->priority = parentParam->priority;
519 }
520 sched->basePrio = parentParam->basePrio;
521
522 sched->initTimeSlice = 0;
523 taskCB->timeSlice = sched->initTimeSlice;
524 taskCB->ops = &g_priorityOps;
525}
const STATIC SchedOps g_priorityOps
Definition: los_priority.c:68
UINT16 usTaskPrio
Definition: los_task.h:505
函数调用图:
这是这个函数的调用关系图:

◆ HPFTimeSliceGet()

STATIC UINT64 HPFTimeSliceGet ( const LosTaskCB taskCB)

在文件 los_priority.c114 行定义.

115{
116 SchedHPF *sched = (SchedHPF *)&taskCB->sp;
117 INT32 timeSlice = taskCB->timeSlice;
118
119 timeSlice = (timeSlice <= OS_TIME_SLICE_MIN) ? sched->initTimeSlice : timeSlice;
120 return (taskCB->startTime + timeSlice);
121}
signed int INT32
Definition: los_typedef.h:60

◆ HPFTimeSliceUpdate()

STATIC VOID HPFTimeSliceUpdate ( SchedRunqueue rq,
LosTaskCB taskCB,
UINT64  currTime 
)

在文件 los_priority.c88 行定义.

89{
90 SchedHPF *sched = (SchedHPF *)&taskCB->sp;
91 LOS_ASSERT(currTime >= taskCB->startTime);
92
93 INT32 incTime = (currTime - taskCB->startTime - taskCB->irqUsedTime);
94
95 LOS_ASSERT(incTime >= 0);
96
97 if (sched->policy == LOS_SCHED_RR) {
98 taskCB->timeSlice -= incTime;
99#ifdef LOSCFG_SCHED_DEBUG
100 taskCB->schedStat.timeSliceRealTime += incTime;
101#endif
102 }
103 taskCB->irqUsedTime = 0;
104 taskCB->startTime = currTime;
105 if (taskCB->timeSlice <= OS_TIME_SLICE_MIN) {
107 }
108
109#ifdef LOSCFG_SCHED_DEBUG
110 taskCB->schedStat.allRuntime += incTime;
111#endif
112}
@ INT_PEND_RESCH
Definition: los_sched_pri.h:82
UINT64 timeSliceRealTime
UINT32 irqUsedTime
SchedStat schedStat

◆ HPFWait()

STATIC UINT32 HPFWait ( LosTaskCB runTask,
LOS_DL_LIST list,
UINT32  ticks 
)

在文件 los_priority.c303 行定义.

304{
305 runTask->taskStatus |= OS_TASK_STATUS_PENDING;
306 LOS_ListTailInsert(list, &runTask->pendList);
307
308 if (ticks != LOS_WAIT_FOREVER) {
309 runTask->taskStatus |= OS_TASK_STATUS_PEND_TIME;
310 runTask->waitTime = OS_SCHED_TICK_TO_CYCLE(ticks);
311 }
312
313 if (OsPreemptableInSched()) {
315 if (runTask->taskStatus & OS_TASK_STATUS_TIMEOUT) {
316 runTask->taskStatus &= ~OS_TASK_STATUS_TIMEOUT;
317 return LOS_ERRNO_TSK_TIMEOUT;
318 }
319 }
320
321 return LOS_OK;
322}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
Insert a node to the tail of a doubly linked list.
Definition: los_list.h:244
STATIC INLINE BOOL OsPreemptableInSched(VOID)
函数调用图:

◆ HPFWake()

STATIC VOID HPFWake ( LosTaskCB resumedTask)

在文件 los_priority.c324 行定义.

325{
326 LOS_ListDelete(&resumedTask->pendList);
327 resumedTask->taskStatus &= ~OS_TASK_STATUS_PENDING;
328
329 if (resumedTask->taskStatus & OS_TASK_STATUS_PEND_TIME) {
330 OsSchedTimeoutQueueDelete(resumedTask);
331 resumedTask->taskStatus &= ~OS_TASK_STATUS_PEND_TIME;
332 }
333
334 if (!(resumedTask->taskStatus & OS_TASK_STATUS_SUSPENDED)) {
335#ifdef LOSCFG_SCHED_DEBUG
336 resumedTask->schedStat.pendTime += OsGetCurrSchedTimeCycle() - resumedTask->startTime;
337 resumedTask->schedStat.pendCount++;
338#endif
339 HPFEnqueue(OsSchedRunqueue(), resumedTask);
340 }
341}
函数调用图:

◆ HPFYield()

STATIC VOID HPFYield ( LosTaskCB runTask)

在文件 los_priority.c284 行定义.

285{
287 runTask->timeSlice = 0;
288
290 HPFEnqueue(rq, runTask);
292}
函数调用图:

◆ PriQueDelete()

STATIC INLINE VOID PriQueDelete ( HPFRunqueue rq,
UINT32  basePrio,
LOS_DL_LIST priQue,
UINT32  priority 
)

在文件 los_priority.c187 行定义.

188{
189 HPFQueue *queueList = &rq->queueList[basePrio];
190 LOS_DL_LIST *priQueList = &queueList->priQueList[0];
191 UINT32 *bitmap = &queueList->queueBitmap;
192
193 LOS_ListDelete(priQue);
194 queueList->readyTasks[priority]--;
195 if (LOS_ListEmpty(&priQueList[priority])) {
196 *bitmap &= ~(PRIQUEUE_PRIOR0_BIT >> priority);
197 }
198
199 if (*bitmap == 0) {
200 rq->queueBitmap &= ~(PRIQUEUE_PRIOR0_BIT >> basePrio);
201 }
202}
unsigned int UINT32
Definition: los_typedef.h:57
UINT32 queueBitmap
Definition: los_sched_pri.h:90
UINT32 readyTasks[OS_PRIORITY_QUEUE_NUM]
Definition: los_sched_pri.h:89
UINT32 queueBitmap
Definition: los_sched_pri.h:95
函数调用图:
这是这个函数的调用关系图:

◆ PriQueHeadInsert()

STATIC INLINE VOID PriQueHeadInsert ( HPFRunqueue rq,
UINT32  basePrio,
LOS_DL_LIST priQue,
UINT32  priority 
)

在文件 los_priority.c137 行定义.

138{
139 HPFQueue *queueList = &rq->queueList[basePrio];
140 LOS_DL_LIST *priQueList = &queueList->priQueList[0];
141 UINT32 *bitmap = &queueList->queueBitmap;
142
143 /*
144 * Task control blocks are inited as zero. And when task is deleted,
145 * and at the same time would be deleted from priority queue or
146 * other lists, task pend node will restored as zero.
147 */
148 LOS_ASSERT(priQue->pstNext == NULL);
149
150 if (*bitmap == 0) {
151 rq->queueBitmap |= PRIQUEUE_PRIOR0_BIT >> basePrio;
152 }
153
154 if (LOS_ListEmpty(&priQueList[priority])) {
155 *bitmap |= PRIQUEUE_PRIOR0_BIT >> priority;
156 }
157
158 LOS_ListHeadInsert(&priQueList[priority], priQue);
159 queueList->readyTasks[priority]++;
160}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListHeadInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
Insert a node to the head of a doubly linked list.
Definition: los_list.h:268
struct LOS_DL_LIST * pstNext
Definition: los_list.h:84
函数调用图:
这是这个函数的调用关系图:

◆ PriQueInsert()

STATIC INLINE VOID PriQueInsert ( HPFRunqueue rq,
LosTaskCB taskCB 
)

在文件 los_priority.c204 行定义.

205{
206 LOS_ASSERT(!(taskCB->taskStatus & OS_TASK_STATUS_READY));
207 SchedHPF *sched = (SchedHPF *)&taskCB->sp;
208
209 switch (sched->policy) {
210 case LOS_SCHED_RR: {
211 if (taskCB->timeSlice > OS_TIME_SLICE_MIN) {
212 PriQueHeadInsert(rq, sched->basePrio, &taskCB->pendList, sched->priority);
213 } else {
214 sched->initTimeSlice = TimeSliceCalculate(rq, sched->basePrio, sched->priority);
215 taskCB->timeSlice = sched->initTimeSlice;
216 PriQueTailInsert(rq, sched->basePrio, &taskCB->pendList, sched->priority);
217#ifdef LOSCFG_SCHED_DEBUG
219 taskCB->schedStat.timeSliceCount++;
220#endif
221 }
222 break;
223 }
224 case LOS_SCHED_FIFO: {
225 /* The time slice of FIFO is always greater than 0 unless the yield is called */
226 if ((taskCB->timeSlice > OS_TIME_SLICE_MIN) && (taskCB->taskStatus & OS_TASK_STATUS_RUNNING)) {
227 PriQueHeadInsert(rq, sched->basePrio, &taskCB->pendList, sched->priority);
228 } else {
229 sched->initTimeSlice = OS_SCHED_FIFO_TIMEOUT;
230 taskCB->timeSlice = sched->initTimeSlice;
231 PriQueTailInsert(rq, sched->basePrio, &taskCB->pendList, sched->priority);
232 }
233 break;
234 }
235 default:
236 LOS_ASSERT(0);
237 break;
238 }
239
240 taskCB->taskStatus &= ~OS_TASK_STATUS_BLOCKED;
241 taskCB->taskStatus |= OS_TASK_STATUS_READY;
242}
STATIC INLINE UINT32 TimeSliceCalculate(HPFRunqueue *rq, UINT16 basePrio, UINT16 priority)
Definition: los_priority.c:123
STATIC INLINE VOID PriQueHeadInsert(HPFRunqueue *rq, UINT32 basePrio, LOS_DL_LIST *priQue, UINT32 priority)
Definition: los_priority.c:137
STATIC INLINE VOID PriQueTailInsert(HPFRunqueue *rq, UINT32 basePrio, LOS_DL_LIST *priQue, UINT32 priority)
Definition: los_priority.c:162
UINT64 timeSliceCount
UINT64 timeSliceTime
函数调用图:
这是这个函数的调用关系图:

◆ PriQueTailInsert()

STATIC INLINE VOID PriQueTailInsert ( HPFRunqueue rq,
UINT32  basePrio,
LOS_DL_LIST priQue,
UINT32  priority 
)

在文件 los_priority.c162 行定义.

163{
164 HPFQueue *queueList = &rq->queueList[basePrio];
165 LOS_DL_LIST *priQueList = &queueList->priQueList[0];
166 UINT32 *bitmap = &queueList->queueBitmap;
167
168 /*
169 * Task control blocks are inited as zero. And when task is deleted,
170 * and at the same time would be deleted from priority queue or
171 * other lists, task pend node will restored as zero.
172 */
173 LOS_ASSERT(priQue->pstNext == NULL);
174
175 if (*bitmap == 0) {
176 rq->queueBitmap |= PRIQUEUE_PRIOR0_BIT >> basePrio;
177 }
178
179 if (LOS_ListEmpty(&priQueList[priority])) {
180 *bitmap |= PRIQUEUE_PRIOR0_BIT >> priority;
181 }
182
183 LOS_ListTailInsert(&priQueList[priority], priQue);
184 queueList->readyTasks[priority]++;
185}
函数调用图:
这是这个函数的调用关系图:

◆ TimeSliceCalculate()

STATIC INLINE UINT32 TimeSliceCalculate ( HPFRunqueue rq,
UINT16  basePrio,
UINT16  priority 
)

在文件 los_priority.c123 行定义.

124{
125 UINT32 time;
126 UINT32 readyTasks;
127
128 HPFQueue *queueList = &rq->queueList[basePrio];
129 readyTasks = queueList->readyTasks[priority];
130 if (readyTasks > OS_SCHED_READY_MAX) {
131 return OS_SCHED_TIME_SLICES_MIN;
132 }
133 time = ((OS_SCHED_READY_MAX - readyTasks) * OS_SCHED_TIME_SLICES_DIFF) / OS_SCHED_READY_MAX;
134 return (time + OS_SCHED_TIME_SLICES_MIN);
135}
time_t time(time_t *t)
Definition: time.c:1224
函数调用图:
这是这个函数的调用关系图:

变量说明

◆ g_priorityOps

const STATIC SchedOps g_priorityOps
初始值:
= {
.dequeue = HPFDequeue,
.enqueue = HPFEnqueue,
.wait = HPFWait,
.wake = HPFWake,
.schedParamModify = HPFSchedParamModify,
.schedParamGet = HPFSchedParamGet,
.delay = HPFDelay,
.yield = HPFYield,
.start = HPFStartToRun,
.exit = HPFExit,
.suspend = HPFSuspend,
.resume = HPFResume,
.deadlineGet = HPFTimeSliceGet,
.timeSliceUpdate = HPFTimeSliceUpdate,
.schedParamCompare = HPFParamCompare,
.priorityInheritance = HPFPriorityInheritance,
.priorityRestore = HPFPriorityRestore,
}
STATIC VOID HPFPriorityInheritance(LosTaskCB *owner, const SchedParam *param)
Definition: los_priority.c:454
STATIC UINT32 HPFDelay(LosTaskCB *runTask, UINT64 waitTime)
Definition: los_priority.c:294
STATIC UINT32 HPFSuspend(LosTaskCB *taskCB)
Definition: los_priority.c:411
STATIC UINT32 HPFSchedParamGet(const LosTaskCB *taskCB, SchedParam *param)
Definition: los_priority.c:401
STATIC VOID HPFYield(LosTaskCB *runTask)
Definition: los_priority.c:284
STATIC VOID HPFExit(LosTaskCB *taskCB)
Definition: los_priority.c:269
STATIC INT32 HPFParamCompare(const SchedPolicy *sp1, const SchedPolicy *sp2)
Definition: los_priority.c:442
STATIC VOID HPFStartToRun(SchedRunqueue *rq, LosTaskCB *taskCB)
Definition: los_priority.c:264
STATIC UINT32 HPFWait(LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 ticks)
Definition: los_priority.c:303
STATIC UINT32 HPFResume(LosTaskCB *taskCB, BOOL *needSched)
Definition: los_priority.c:427
STATIC VOID HPFTimeSliceUpdate(SchedRunqueue *rq, LosTaskCB *taskCB, UINT64 currTime)
Definition: los_priority.c:88
STATIC BOOL HPFSchedParamModify(LosTaskCB *taskCB, const SchedParam *param)
Definition: los_priority.c:365
STATIC UINT64 HPFTimeSliceGet(const LosTaskCB *taskCB)
Definition: los_priority.c:114
STATIC VOID HPFPriorityRestore(LosTaskCB *owner, const LOS_DL_LIST *list, const SchedParam *param)
恢复任务优先级
Definition: los_priority.c:470
STATIC VOID HPFWake(LosTaskCB *resumedTask)
Definition: los_priority.c:324

在文件 los_priority.c68 行定义.

◆ g_schedHPF

STATIC HPFRunqueue g_schedHPF

在文件 los_priority.c48 行定义.