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

浏览源代码.

函数

STATIC VOID TaskCpupInfoBaseGet (UINTPTR base, const CPUP_INFO_S **, const CPUP_INFO_S **, const CPUP_INFO_S **)
 
STATIC VOID ProcessCpupInfoBaseGet (UINTPTR base, const CPUP_INFO_S **, const CPUP_INFO_S **, const CPUP_INFO_S **)
 
STATIC UINT8ConvertProcessModeToString (UINT16 mode)
 
STATIC UINT8ConvertSchedPolicyToString (UINT16 policy)
 
STATIC UINT8ConvertProcessStatusToString (UINT16 status)
 
STATIC VOID ProcessInfoTitle (VOID *seqBuf, UINT16 flag)
 
STATIC VOID AllProcessDataShow (const LosProcessCB *pcbArray, const SchedParam *param, UINTPTR cpupInfo, VOID *seqBuf, UINT16 flag)
 
STATIC VOID ProcessMemUsageGet (LosProcessCB *pcbArray)
 
STATIC VOID ProcessInfoGet (LosProcessCB **pcbArray, LosTaskCB **tcbArray, SchedParam **schedParam)
 
STATIC VOID ProcessInfoShow (const LosProcessCB *pcbArray, const SchedParam *param, UINTPTR cpupInfo, VOID *seqBuf, UINT16 flag)
 
STATIC UINT8ConvertTaskStatusToString (UINT16 taskStatus)
 
STATIC VOID TaskWaterLineGet (UINTPTR waterLineBase, LosTaskCB *tcbArray)
 
STATIC CHARCheckTaskWaitFlag (const LosTaskCB *taskCB, UINTPTR *lockID)
 
STATIC VOID TaskPendingReasonInfoGet (const LosTaskCB *taskCB, CHAR *pendReason, UINT32 maxLen, UINTPTR *lockID)
 
STATIC VOID TaskInfoTitle (VOID *seqBuf, UINT16 flag)
 
STATIC VOID AllTaskInfoDataShow (const LosTaskCB *allTaskArray, UINTPTR cpupInfo, VOID *seqBuf, UINT16 flag)
 
STATIC VOID TaskInfoData (const LosTaskCB *allTaskArray, UINTPTR cpupInfo, VOID *seqBuf, UINT16 flag)
 
STATIC VOID TaskCpupInfoGet (UINTPTR base)
 
STATIC VOID ProcessAndTaskInfoGet (LosProcessCB **pcbArray, LosTaskCB **tcbArray, SchedParam **schedParam, UINTPTR *cpupInfo, UINT16 flag)
 
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdTskInfoGet (UINT32 taskID, VOID *seqBuf, UINT16 flag)
 
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdDumpTask (INT32 argc, const CHAR **argv)
 
 SHELLCMD_ENTRY (task_shellcmd, CMD_TYPE_EX, "task", 1,(CmdCallBackFunc) OsShellCmdDumpTask)
 

函数说明

◆ AllProcessDataShow()

STATIC VOID AllProcessDataShow ( const LosProcessCB pcbArray,
const SchedParam param,
UINTPTR  cpupInfo,
VOID *  seqBuf,
UINT16  flag 
)

在文件 task_shellcmd.c160 行定义.

162{
163 const INT32 *group = (const INT32 *)((UINTPTR)pcbArray + OS_PROCESS_INFO_LEN);
164 const INT32 *user = (const INT32 *)((UINTPTR)group + OS_PROCESS_GROUP_INFO_LEN);
165 const UINT32 *memArray = (const UINT32 *)((UINTPTR)pcbArray + OS_PROCESS_ALL_INFO_LEN);
166#ifdef LOSCFG_KERNEL_CPUP
167 const CPUP_INFO_S *cpupAll = NULL;
168 const CPUP_INFO_S *cpup10s = NULL;
169 const CPUP_INFO_S *cpup1s = NULL;
170 ProcessCpupInfoBaseGet(cpupInfo, &cpupAll, &cpup10s, &cpup1s);
171#else
172 (VOID)cpupInfo;
173#endif
174
175 for (UINT32 pid = 1; pid < g_processMaxNum; ++pid) {
176 const LosProcessCB *processCB = pcbArray + pid;
177 if (OsProcessIsUnused(processCB)) {
178 continue;
179 }
180
181 SHOW("%5u%6d%5d%6d%7s%8s%7s%9u%5u%7u", pid, (INT32)processCB->parentProcessID, group[pid], user[pid],
183 ConvertSchedPolicyToString(LOS_SCHED_RR), param[processCB->threadGroupID].basePrio,
184 processCB->threadGroupID, processCB->threadNumber);
185
186 if (flag & OS_PROCESS_INFO_ALL) {
187 if (flag & OS_PROCESS_MEM_INFO) {
188 const UINT32 *memUsage = &memArray[pid * PROCESS_VM_INDEX_MAX];
189 SHOW("%#11x%#9x%#12x", memUsage[VM_INDEX], memUsage[SM_INDEX], memUsage[PM_INDEX]);
190 }
191#ifdef LOSCFG_KERNEL_CPUP
192 SHOW("%4u.%-2u%7u.%-2u%6u.%-2u ", cpupAll[pid].usage / CPUP_MULT, cpupAll[pid].usage % CPUP_MULT,
193 cpup10s[pid].usage / CPUP_MULT, cpup10s[pid].usage % CPUP_MULT,
194 cpup1s[pid].usage / CPUP_MULT, cpup1s[pid].usage % CPUP_MULT);
195#endif /* LOSCFG_KERNEL_CPUP */
196 } else {
197#ifdef LOSCFG_KERNEL_CPUP
198 SHOW("%7u.%-2u ", cpup10s[pid].usage / CPUP_MULT, cpup10s[pid].usage % CPUP_MULT);
199#endif /* LOSCFG_KERNEL_CPUP */
200 }
201 SHOW("%-32s\n", processCB->processName);
202 }
203}
LITE_OS_SEC_BSS UINT32 g_processMaxNum
进程最大数量,默认64个
Definition: los_process.c:86
STATIC INLINE BOOL OsProcessIsUnused(const LosProcessCB *processCB)
signed int INT32
Definition: los_typedef.h:60
unsigned long UINTPTR
Definition: los_typedef.h:68
unsigned int UINT32
Definition: los_typedef.h:57
UINT16 processMode
UINT32 threadGroupID
UINT16 processStatus
CHAR processName[OS_PCB_NAME_LEN]
volatile UINT32 threadNumber
UINT32 parentProcessID
STATIC UINT8 * ConvertProcessStatusToString(UINT16 status)
STATIC VOID ProcessCpupInfoBaseGet(UINTPTR base, const CPUP_INFO_S **, const CPUP_INFO_S **, const CPUP_INFO_S **)
STATIC UINT8 * ConvertProcessModeToString(UINT16 mode)
STATIC UINT8 * ConvertSchedPolicyToString(UINT16 policy)
函数调用图:
这是这个函数的调用关系图:

◆ AllTaskInfoDataShow()

STATIC VOID AllTaskInfoDataShow ( const LosTaskCB allTaskArray,
UINTPTR  cpupInfo,
VOID *  seqBuf,
UINT16  flag 
)

在文件 task_shellcmd.c451 行定义.

452{
453 const SchedParam *param = (const SchedParam *)((UINTPTR)allTaskArray + OS_TASK_INFO_LEN);
454 const UINT32 *waterLine = (const UINT32 *)((UINTPTR)allTaskArray + OS_TASK_INFO_LEN + OS_TASK_SCHED_INFO_LEN);
455#ifdef LOSCFG_KERNEL_CPUP
456 const CPUP_INFO_S *cpupAll = NULL;
457 const CPUP_INFO_S *cpup10s = NULL;
458 const CPUP_INFO_S *cpup1s = NULL;
459 TaskCpupInfoBaseGet(cpupInfo, &cpupAll, &cpup10s, &cpup1s);
460#else
461 (VOID)cpupInfo;
462#endif
463 for (UINT32 pid = 1; pid < g_processMaxNum; ++pid) {
464 for (UINT32 tid = 0; tid < g_taskMaxNum; ++tid) {
465 const LosTaskCB *taskCB = allTaskArray + tid;
466 if (OsTaskIsUnused(taskCB) || (taskCB->processID != pid)) {
467 continue;
468 }
469#ifdef LOSCFG_SHELL_CMD_DEBUG
470 UINTPTR lockID = 0;
471 CHAR pendReason[OS_PEND_REASON_MAX_LEN] = { 0 };
472#endif
473 SHOW(" %4u%5u", tid, taskCB->processID);
474
475#ifdef LOSCFG_KERNEL_SMP
476 SHOW("%#5x%4d ", taskCB->cpuAffiMask, (INT16)(taskCB->currCpu));
477#endif
478 SHOW("%9s%7s%9u%#10x%#10x", ConvertTaskStatusToString(taskCB->taskStatus),
479 ConvertSchedPolicyToString(param[tid].policy), param[tid].priority, taskCB->stackSize, waterLine[tid]);
480 if (flag & OS_PROCESS_INFO_ALL) {
481#ifdef LOSCFG_KERNEL_CPUP
482 SHOW("%4u.%-2u%7u.%-2u%6u.%-2u ", cpupAll[tid].usage / CPUP_MULT, cpupAll[tid].usage % CPUP_MULT,
483 cpup10s[tid].usage / CPUP_MULT, cpup10s[tid].usage % CPUP_MULT,
484 cpup1s[tid].usage / CPUP_MULT, cpup1s[tid].usage % CPUP_MULT);
485#endif /* LOSCFG_KERNEL_CPUP */
486#ifdef LOSCFG_SHELL_CMD_DEBUG
487 TaskPendingReasonInfoGet(taskCB, pendReason, OS_PEND_REASON_MAX_LEN, &lockID);
488 SHOW("%#12x%#12x%11s%#11x", taskCB->stackPointer, taskCB->topOfStack, pendReason, lockID);
489#endif
490 } else {
491#ifdef LOSCFG_KERNEL_CPUP
492 SHOW("%8u.%-2u ", cpup10s[tid].usage / CPUP_MULT, cpup10s[tid].usage % CPUP_MULT);
493#endif /* LOSCFG_KERNEL_CPUP */
494 }
495 SHOW(" %-32s\n", taskCB->taskName);
496 }
497 }
498}
LITE_OS_SEC_BSS UINT32 g_taskMaxNum
任务最大数量 默认128个
Definition: los_task.c:150
STATIC INLINE BOOL OsTaskIsUnused(const LosTaskCB *taskCB)
任务是否在使用
Definition: los_task_pri.h:255
signed short INT16
Definition: los_typedef.h:59
char CHAR
Definition: los_typedef.h:63
UINT16 cpuAffiMask
UINT32 stackSize
CHAR taskName[OS_TCB_NAME_LEN]
UINTPTR topOfStack
VOID * stackPointer
UINT16 currCpu
UINT32 processID
UINT16 taskStatus
STATIC VOID TaskCpupInfoBaseGet(UINTPTR base, const CPUP_INFO_S **, const CPUP_INFO_S **, const CPUP_INFO_S **)
STATIC VOID TaskPendingReasonInfoGet(const LosTaskCB *taskCB, CHAR *pendReason, UINT32 maxLen, UINTPTR *lockID)
STATIC UINT8 * ConvertTaskStatusToString(UINT16 taskStatus)
函数调用图:
这是这个函数的调用关系图:

◆ CheckTaskWaitFlag()

STATIC CHAR * CheckTaskWaitFlag ( const LosTaskCB taskCB,
UINTPTR lockID 
)

在文件 task_shellcmd.c363 行定义.

364{
365 *lockID = taskCB->waitID;
366 switch (taskCB->waitFlag) {
367 case OS_TASK_WAIT_PROCESS:
368 return "Child";
369 case OS_TASK_WAIT_GID:
370 return "PGroup";
371 case OS_TASK_WAIT_ANYPROCESS:
372 return "AnyChild";
373 case OS_TASK_WAIT_SEM:
374 return "Semaphore";
375 case OS_TASK_WAIT_QUEUE:
376 return "Queue";
377 case OS_TASK_WAIT_JOIN:
378 return "Join";
379 case OS_TASK_WAIT_SIGNAL:
380 return "Signal";
381 case OS_TASK_WAIT_LITEIPC:
382 return "LiteIPC";
383 case OS_TASK_WAIT_MUTEX:
384 return "Mutex";
385 case OS_TASK_WAIT_EVENT:
386 return "Event";
387 case OS_TASK_WAIT_FUTEX:
388 return "Futex";
389 case OS_TASK_WAIT_COMPLETE:
390 return "Complete";
391 default:
392 break;
393 }
394
395 return NULL;
396}
UINTPTR waitID
UINT16 waitFlag
这是这个函数的调用关系图:

◆ ConvertProcessModeToString()

STATIC UINT8 * ConvertProcessModeToString ( UINT16  mode)

在文件 task_shellcmd.c104 行定义.

105{
106 if (mode == OS_KERNEL_MODE) {
107 return (UINT8 *)"kernel";
108 } else if (mode == OS_USER_MODE) {
109 return (UINT8 *)"user";
110 }
111
112 return (UINT8 *)"ERROR";
113}
unsigned char UINT8
Definition: los_typedef.h:55
这是这个函数的调用关系图:

◆ ConvertProcessStatusToString()

STATIC UINT8 * ConvertProcessStatusToString ( UINT16  status)

在文件 task_shellcmd.c128 行定义.

129{
130 if (status & OS_PROCESS_STATUS_ZOMBIES) {
131 return (UINT8 *)"Zombies";
132 } else if (status & OS_PROCESS_STATUS_INIT) {
133 return (UINT8 *)"Init";
134 } else if (status & OS_PROCESS_STATUS_RUNNING) {
135 return (UINT8 *)"Running";
136 } else if (status & OS_PROCESS_STATUS_READY) {
137 return (UINT8 *)"Ready";
138 }
139 return (UINT8 *)"Pending";
140}
这是这个函数的调用关系图:

◆ ConvertSchedPolicyToString()

STATIC UINT8 * ConvertSchedPolicyToString ( UINT16  policy)

在文件 task_shellcmd.c115 行定义.

116{
117 if (policy == LOS_SCHED_RR) {
118 return (UINT8 *)"RR";
119 } else if (policy == LOS_SCHED_FIFO) {
120 return (UINT8 *)"FIFO";
121 } else if (policy == LOS_SCHED_IDLE) {
122 return (UINT8 *)"IDLE";
123 }
124
125 return (UINT8 *)"ERROR";
126}
这是这个函数的调用关系图:

◆ ConvertTaskStatusToString()

STATIC UINT8 * ConvertTaskStatusToString ( UINT16  taskStatus)

在文件 task_shellcmd.c313 行定义.

314{
315 if (taskStatus & OS_TASK_STATUS_INIT) {
316 return (UINT8 *)"Init";
317 } else if (taskStatus & OS_TASK_STATUS_RUNNING) {
318 return (UINT8 *)"Running";
319 } else if (taskStatus & OS_TASK_STATUS_READY) {
320 return (UINT8 *)"Ready";
321 } else if (taskStatus & OS_TASK_STATUS_FROZEN) {
322 return (UINT8 *)"Frozen";
323 } else if (taskStatus & OS_TASK_STATUS_SUSPENDED) {
324 return (UINT8 *)"Suspended";
325 } else if (taskStatus & OS_TASK_STATUS_DELAY) {
326 return (UINT8 *)"Delay";
327 } else if (taskStatus & OS_TASK_STATUS_PENDING) {
328 if (taskStatus & OS_TASK_STATUS_PEND_TIME) {
329 return (UINT8 *)"PendTime";
330 } else {
331 return (UINT8 *)"Pending";
332 }
333 } else if (taskStatus & OS_TASK_STATUS_EXIT) {
334 return (UINT8 *)"Exit";
335 }
336
337 return (UINT8 *)"Invalid";
338}
这是这个函数的调用关系图:

◆ OsShellCmdDumpTask()

LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdDumpTask ( INT32  argc,
const CHAR **  argv 
)

在文件 task_shellcmd.c615 行定义.

616{
617 UINT32 flag = 0;
618#ifdef LOSCFG_KERNEL_VM
619 flag |= OS_PROCESS_MEM_INFO;
620#endif
621
622 if (argc >= 2) { /* 2: The task shell name restricts the parameters */
623 goto TASK_HELP;
624 }
625
626 if (argc == 1) {
627 if (strcmp("-a", argv[0]) == 0) {
628 flag |= OS_PROCESS_INFO_ALL;
629#ifdef LOSCFG_SCHED_DEBUG
630#ifdef LOSCFG_SCHED_TICK_DEBUG
631 } else if (strcmp("-i", argv[0]) == 0) {
633 return LOS_OK;
634 }
635 goto TASK_HELP;
636#endif
637 } else if (strcmp("-t", argv[0]) == 0) {
639 return LOS_OK;
640 }
641 goto TASK_HELP;
642#endif
643 } else {
644 goto TASK_HELP;
645 }
646 }
647
648 return OsShellCmdTskInfoGet(OS_ALL_TASK_MASK, NULL, flag);
649
650TASK_HELP:
651 PRINTK("Unknown option: %s\n", argv[0]);
652 PRINTK("Usage:\n");
653 PRINTK(" task --- Basic information about all created processes.\n");
654 PRINTK(" task -a --- Complete information about all created processes.\n");
655 return LOS_NOK;
656}
UINT32 OsShellShowTickResponse(VOID)
UINT32 OsShellShowSchedStatistics(VOID)
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdTskInfoGet(UINT32 taskID, VOID *seqBuf, UINT16 flag)
函数调用图:

◆ OsShellCmdTskInfoGet()

LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdTskInfoGet ( UINT32  taskID,
VOID *  seqBuf,
UINT16  flag 
)

在文件 task_shellcmd.c585 行定义.

586{
587 UINT32 size;
588 LosProcessCB *pcbArray = NULL;
589 LosTaskCB *tcbArray = NULL;
590 SchedParam *schedParam = NULL;
591 UINTPTR cpupInfo = 0;
592
593 if (taskID == OS_ALL_TASK_MASK) {
594 if (flag & OS_PROCESS_MEM_INFO) {
595 size = OS_PROCESS_ALL_INFO_LEN + OS_PROCESS_MEM_ALL_INFO_LEN + OS_TASK_ALL_INFO_LEN;
596 } else {
597 size = OS_PROCESS_ALL_INFO_LEN + OS_TASK_ALL_INFO_LEN;
598 }
599 pcbArray = (LosProcessCB *)LOS_MemAlloc(m_aucSysMem1, size);
600 if (pcbArray == NULL) {
601 PRINT_ERR("Memory is not enough to save task info!\n");
602 return LOS_NOK;
603 }
604 (VOID)memset_s(pcbArray, size, 0, size);
605 ProcessAndTaskInfoGet(&pcbArray, &tcbArray, &schedParam, &cpupInfo, flag);
606 ProcessInfoShow(pcbArray, schedParam, cpupInfo, seqBuf, flag);
607 TaskInfoData(tcbArray, cpupInfo, seqBuf, flag);
608
609 (VOID)LOS_MemFree(m_aucSysMem1, pcbArray);
610 }
611
612 return LOS_OK;
613}
VOID * LOS_MemAlloc(VOID *pool, UINT32 size)
从指定内存池中申请size长度的内存,注意这可不是从内核堆空间中申请内存
Definition: los_memory.c:1123
UINT8 * m_aucSysMem1
系统动态内存池地址的起始地址 @note_thinking 能否不要用 0,1来命名核心变量 ???
Definition: los_memory.c:108
UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
释放从指定动态内存中申请的内存
Definition: los_memory.c:1369
STATIC VOID ProcessAndTaskInfoGet(LosProcessCB **pcbArray, LosTaskCB **tcbArray, SchedParam **schedParam, UINTPTR *cpupInfo, UINT16 flag)
STATIC VOID ProcessInfoShow(const LosProcessCB *pcbArray, const SchedParam *param, UINTPTR cpupInfo, VOID *seqBuf, UINT16 flag)
STATIC VOID TaskInfoData(const LosTaskCB *allTaskArray, UINTPTR cpupInfo, VOID *seqBuf, UINT16 flag)
函数调用图:
这是这个函数的调用关系图:

◆ ProcessAndTaskInfoGet()

STATIC VOID ProcessAndTaskInfoGet ( LosProcessCB **  pcbArray,
LosTaskCB **  tcbArray,
SchedParam **  schedParam,
UINTPTR cpupInfo,
UINT16  flag 
)

在文件 task_shellcmd.c551 行定义.

553{
554 UINT32 intSave;
555 UINT32 processInfoLen = OS_PROCESS_ALL_INFO_LEN;
556
557#ifdef LOSCFG_KERNEL_VM
558 if (flag & OS_PROCESS_MEM_INFO) {
559 processInfoLen += OS_PROCESS_MEM_ALL_INFO_LEN;
560 }
561#endif
562
563 SCHEDULER_LOCK(intSave);
564 (VOID)memcpy_s(*pcbArray, OS_PROCESS_INFO_LEN, g_processCBArray, OS_PROCESS_INFO_LEN);
565 *tcbArray = (LosTaskCB *)((UINTPTR)*pcbArray + processInfoLen);
566 (VOID)memcpy_s(*tcbArray, OS_TASK_INFO_LEN, g_taskCBArray, OS_TASK_INFO_LEN);
567
568 ProcessInfoGet(pcbArray, tcbArray, schedParam);
569 SCHEDULER_UNLOCK(intSave);
570
571#ifdef LOSCFG_KERNEL_CPUP
572 *cpupInfo = (UINTPTR)*pcbArray + OS_PROCESS_INFO_LEN + OS_PROCESS_GROUP_INFO_LEN;
573 TaskCpupInfoGet(*cpupInfo);
574#endif
575
576#ifdef LOSCFG_KERNEL_VM
577 if (flag & OS_PROCESS_MEM_INFO) {
578 ProcessMemUsageGet(*pcbArray);
579 }
580#endif
581
582 TaskWaterLineGet((UINTPTR)*tcbArray + OS_TASK_INFO_LEN + OS_TASK_SCHED_INFO_LEN, *tcbArray);
583}
LITE_OS_SEC_BSS LosTaskCB * g_taskCBArray
外部变量 任务池 默认128个
Definition: los_task.c:147
LITE_OS_SEC_BSS LosProcessCB * g_processCBArray
进程池数组
Definition: los_process.c:80
STATIC VOID ProcessInfoGet(LosProcessCB **pcbArray, LosTaskCB **tcbArray, SchedParam **schedParam)
STATIC VOID TaskWaterLineGet(UINTPTR waterLineBase, LosTaskCB *tcbArray)
STATIC VOID TaskCpupInfoGet(UINTPTR base)
STATIC VOID ProcessMemUsageGet(LosProcessCB *pcbArray)
函数调用图:
这是这个函数的调用关系图:

◆ ProcessCpupInfoBaseGet()

STATIC VOID ProcessCpupInfoBaseGet ( UINTPTR  base,
const CPUP_INFO_S **  cpupAll,
const CPUP_INFO_S **  cpup10s,
const CPUP_INFO_S **  cpup1s 
)

在文件 task_shellcmd.c518 行定义.

520{
521 *cpupAll = (CPUP_INFO_S *)(base + OS_PROCESS_UID_INFO_LEN);
522 *cpup10s = (CPUP_INFO_S *)((UINTPTR)*cpupAll + OS_PROCESS_AND_TASK_CPUP_LEN);
523 *cpup1s = (CPUP_INFO_S *)((UINTPTR)*cpup10s + OS_PROCESS_AND_TASK_CPUP_LEN);
524}
这是这个函数的调用关系图:

◆ ProcessInfoGet()

STATIC VOID ProcessInfoGet ( LosProcessCB **  pcbArray,
LosTaskCB **  tcbArray,
SchedParam **  schedParam 
)

在文件 task_shellcmd.c250 行定义.

251{
252 INT32 *group = (INT32 *)((UINTPTR)*pcbArray + OS_PROCESS_INFO_LEN);
253 INT32 *user = (INT32 *)((UINTPTR)group + OS_PROCESS_GROUP_INFO_LEN);
254 SchedParam *param = (SchedParam *)((UINTPTR)*tcbArray + OS_TASK_INFO_LEN);
255 *schedParam = param;
256
257 for (UINT32 tid = 0; tid < g_taskMaxNum; tid++) {
258 const LosTaskCB *taskCB = *tcbArray + tid;
259 if (OsTaskIsUnused(taskCB)) {
260 continue;
261 }
262
263 LosProcessCB *processCB = *pcbArray + taskCB->processID;
264 if (!OsProcessIsDead(processCB) && !OsProcessIsInit(processCB)) {
265 processCB->processStatus |= (taskCB->taskStatus & OS_TASK_STATUS_MASK);
266 }
267 taskCB->ops->schedParamGet(taskCB, &param[tid]);
268 }
269
270 for (UINT32 pid = 0; pid < g_processMaxNum; ++pid) {
271 const LosProcessCB *processCB = *pcbArray + pid;
272 if (OsProcessIsUnused(processCB)) {
273 continue;
274 }
275
276 if (processCB->group != NULL) {
277 group[processCB->processID] = processCB->group->groupID;
278 } else {
279 group[processCB->processID] = -1;
280 }
281
282#ifdef LOSCFG_SECURITY_CAPABILITY
283 if (processCB->user != NULL) {
284 user[processCB->processID] = processCB->user->userID;
285 } else {
286 user[processCB->processID] = -1;
287 }
288#else
289 user[processCB->processID] = 0;
290#endif
291 }
292}
STATIC INLINE BOOL OsProcessIsInit(const LosProcessCB *processCB)
STATIC INLINE BOOL OsProcessIsDead(const LosProcessCB *processCB)
进程死啦死啦的定义: 身上贴有不使用且状态为僵死的进程
UINT32 processID
User * user
进程的拥有者
ProcessGroup * group
UINT32(* schedParamGet)(const LosTaskCB *taskCB, SchedParam *param)
获取调度参数
const SchedOps * ops
UINT32 userID
用户ID [0,60000],0为root用户
函数调用图:
这是这个函数的调用关系图:

◆ ProcessInfoShow()

STATIC VOID ProcessInfoShow ( const LosProcessCB pcbArray,
const SchedParam param,
UINTPTR  cpupInfo,
VOID *  seqBuf,
UINT16  flag 
)

在文件 task_shellcmd.c294 行定义.

296{
297#ifdef LOSCFG_KERNEL_CPUP
298 const CPUP_INFO_S *cpupAll = NULL;
299 const CPUP_INFO_S *cpup10s = NULL;
300 const CPUP_INFO_S *cpup1s = NULL;
301 ProcessCpupInfoBaseGet(cpupInfo, &cpupAll, &cpup10s, &cpup1s);
303 UINT32 sysUsage = LOS_CPUP_PRECISION - cpupAll[pid].usage;
304
305 SHOW("\n allCpu(%%): %4u.%02u sys, %4u.%02u idle\n", sysUsage / CPUP_MULT, sysUsage % CPUP_MULT,
306 cpupAll[pid].usage / CPUP_MULT, cpupAll[pid].usage % CPUP_MULT);
307#endif
308
309 ProcessInfoTitle(seqBuf, flag);
310 AllProcessDataShow(pcbArray, param, cpupInfo, seqBuf, flag);
311}
LITE_OS_SEC_TEXT UINT32 OsGetIdleProcessID(VOID)
获取内核态空闲进程
Definition: los_process.c:2254
UINT32 usage
Definition: los_cpup.h:124
STATIC VOID AllProcessDataShow(const LosProcessCB *pcbArray, const SchedParam *param, UINTPTR cpupInfo, VOID *seqBuf, UINT16 flag)
STATIC VOID ProcessInfoTitle(VOID *seqBuf, UINT16 flag)
函数调用图:
这是这个函数的调用关系图:

◆ ProcessInfoTitle()

STATIC VOID ProcessInfoTitle ( VOID *  seqBuf,
UINT16  flag 
)

在文件 task_shellcmd.c142 行定义.

143{
144 SHOW("\r\n PID PPID PGID UID Mode Status Policy Priority MTID TTotal");
145 if (flag & OS_PROCESS_INFO_ALL) {
146 if (flag & OS_PROCESS_MEM_INFO) {
147 SHOW(" VirtualMem ShareMem PhysicalMem");
148 }
149#ifdef LOSCFG_KERNEL_CPUP
150 SHOW(" CPUUSE CPUUSE10s CPUUSE1s");
151#endif /* LOSCFG_KERNEL_CPUP */
152 } else {
153#ifdef LOSCFG_KERNEL_CPUP
154 SHOW(" CPUUSE10s");
155#endif /* LOSCFG_KERNEL_CPUP */
156 }
157 SHOW(" PName\n");
158}
这是这个函数的调用关系图:

◆ ProcessMemUsageGet()

STATIC VOID ProcessMemUsageGet ( LosProcessCB pcbArray)

在文件 task_shellcmd.c206 行定义.

207{
208 UINT32 intSave, memUsed;
209 UINT32 *memArray = (UINT32 *)((UINTPTR)pcbArray + OS_PROCESS_ALL_INFO_LEN);
210
211 for (UINT32 pid = 0; pid < g_processMaxNum; ++pid) {
212 const LosProcessCB *processCB = g_processCBArray + pid;
213 UINT32 *proMemUsage = &memArray[pid * PROCESS_VM_INDEX_MAX];
214
215 SCHEDULER_LOCK(intSave);
216 if (OsProcessIsUnused(processCB)) {
217 SCHEDULER_UNLOCK(intSave);
218 pcbArray[pid].processStatus = OS_PROCESS_FLAG_UNUSED;
219 continue;
220 }
221
222 LosVmSpace *vmSpace = processCB->vmSpace;
223 SCHEDULER_UNLOCK(intSave);
224
225 /* Process memory usage statistics, idle task defaults to 0 */
226 if (pid == OsGetIdleProcessID()) {
227 proMemUsage[VM_INDEX] = 0;
228 proMemUsage[SM_INDEX] = 0;
229 proMemUsage[PM_INDEX] = 0;
230 } else if (vmSpace == LOS_GetKVmSpace()) {
231 (VOID)OsShellCmdProcessPmUsage(vmSpace, &proMemUsage[SM_INDEX], &proMemUsage[PM_INDEX]);
232 proMemUsage[VM_INDEX] = proMemUsage[PM_INDEX];
233 } else {
234 memUsed = OsShellCmdProcessVmUsage(vmSpace);
235 if (memUsed == 0) {
236 pcbArray[pid].processStatus = OS_PROCESS_FLAG_UNUSED;
237 continue;
238 }
239 proMemUsage[VM_INDEX] = memUsed;
240 memUsed = OsShellCmdProcessPmUsage(vmSpace, &proMemUsage[SM_INDEX], &proMemUsage[PM_INDEX]);
241 if (memUsed == 0) {
242 pcbArray[pid].processStatus = OS_PROCESS_FLAG_UNUSED;
243 }
244 }
245 }
246}
UINT32 OsShellCmdProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm)
shell task 物理内存的使用情况
Definition: los_vm_dump.c:183
UINT32 OsShellCmdProcessVmUsage(LosVmSpace *space)
shell task 进程虚拟内存的使用情况
Definition: los_vm_dump.c:111
LosVmSpace * LOS_GetKVmSpace(VOID)
内核空间只有g_kVmSpace一个,所有的内核进程都共用一个内核空间
Definition: los_vm_map.c:130
LosVmSpace * vmSpace
虚拟空间,每个进程都有一个属于自己的虚拟内存地址空间
Definition: los_vm_map.h:146
函数调用图:
这是这个函数的调用关系图:

◆ SHELLCMD_ENTRY()

SHELLCMD_ENTRY ( task_shellcmd  ,
CMD_TYPE_EX  ,
"task"  ,
,
(CmdCallBackFunc OsShellCmdDumpTask 
)

◆ TaskCpupInfoBaseGet()

STATIC VOID TaskCpupInfoBaseGet ( UINTPTR  base,
const CPUP_INFO_S **  cpupAll,
const CPUP_INFO_S **  cpup10s,
const CPUP_INFO_S **  cpup1s 
)

在文件 task_shellcmd.c507 行定义.

509{
510 UINTPTR processCpupAll = base + OS_PROCESS_UID_INFO_LEN;
511 *cpupAll = (CPUP_INFO_S *)(processCpupAll + OS_PROCESS_CPUP_LEN);
512 UINTPTR processCpup10s = processCpupAll + OS_PROCESS_AND_TASK_CPUP_LEN;
513 *cpup10s = (CPUP_INFO_S *)(processCpup10s + OS_PROCESS_CPUP_LEN);
514 UINTPTR processCpup1s = processCpup10s + OS_PROCESS_AND_TASK_CPUP_LEN;
515 *cpup1s = (CPUP_INFO_S *)(processCpup1s + OS_PROCESS_CPUP_LEN);
516}
这是这个函数的调用关系图:

◆ TaskCpupInfoGet()

STATIC VOID TaskCpupInfoGet ( UINTPTR  base)

在文件 task_shellcmd.c526 行定义.

527{
528 UINT32 intSave;
529
530 CPUP_INFO_S *processCpupAll = (CPUP_INFO_S *)(base + OS_PROCESS_UID_INFO_LEN);
531 CPUP_INFO_S *processCpup10s = (CPUP_INFO_S *)((UINTPTR)processCpupAll + OS_PROCESS_AND_TASK_CPUP_LEN);
532 CPUP_INFO_S *processCpup1s = (CPUP_INFO_S *)((UINTPTR)processCpup10s + OS_PROCESS_AND_TASK_CPUP_LEN);
533
534 SCHEDULER_LOCK(intSave);
535 (VOID)OsGetAllProcessAndTaskCpuUsageUnsafe(CPUP_ALL_TIME, processCpupAll, OS_PROCESS_AND_TASK_CPUP_LEN);
536 SCHEDULER_UNLOCK(intSave);
537
538 SCHEDULER_LOCK(intSave);
539 (VOID)OsGetAllProcessAndTaskCpuUsageUnsafe(CPUP_LAST_TEN_SECONDS, processCpup10s, OS_PROCESS_AND_TASK_CPUP_LEN);
540 SCHEDULER_UNLOCK(intSave);
541
542 SCHEDULER_LOCK(intSave);
543 (VOID)OsGetAllProcessAndTaskCpuUsageUnsafe(CPUP_LAST_ONE_SECONDS, processCpup1s, OS_PROCESS_AND_TASK_CPUP_LEN);
544 SCHEDULER_UNLOCK(intSave);
545}
@ CPUP_LAST_TEN_SECONDS
Definition: los_cpup.h:132
@ CPUP_ALL_TIME
Definition: los_cpup.h:134
@ CPUP_LAST_ONE_SECONDS
Definition: los_cpup.h:133
LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllProcessAndTaskCpuUsageUnsafe(UINT16 mode, CPUP_INFO_S *cpupInfo, UINT32 len)
Definition: los_cpup.c:595
函数调用图:
这是这个函数的调用关系图:

◆ TaskInfoData()

STATIC VOID TaskInfoData ( const LosTaskCB allTaskArray,
UINTPTR  cpupInfo,
VOID *  seqBuf,
UINT16  flag 
)

在文件 task_shellcmd.c500 行定义.

501{
502 TaskInfoTitle(seqBuf, flag);
503 AllTaskInfoDataShow(allTaskArray, cpupInfo, seqBuf, flag);
504}
STATIC VOID AllTaskInfoDataShow(const LosTaskCB *allTaskArray, UINTPTR cpupInfo, VOID *seqBuf, UINT16 flag)
STATIC VOID TaskInfoTitle(VOID *seqBuf, UINT16 flag)
函数调用图:
这是这个函数的调用关系图:

◆ TaskInfoTitle()

STATIC VOID TaskInfoTitle ( VOID *  seqBuf,
UINT16  flag 
)

在文件 task_shellcmd.c429 行定义.

430{
431 SHOW("\r\n TID PID");
432#ifdef LOSCFG_KERNEL_SMP
433 SHOW(" Affi CPU");
434#endif
435 SHOW(" Status Policy Priority StackSize WaterLine");
436 if (flag & OS_PROCESS_INFO_ALL) {
437#ifdef LOSCFG_KERNEL_CPUP
438 SHOW(" CPUUSE CPUUSE10s CPUUSE1s");
439#endif /* LOSCFG_KERNEL_CPUP */
440#ifdef LOSCFG_SHELL_CMD_DEBUG
441 SHOW(" StackPoint TopOfStack PendReason LockID");
442#endif
443 } else {
444#ifdef LOSCFG_KERNEL_CPUP
445 SHOW(" CPUUSE10s ");
446#endif /* LOSCFG_KERNEL_CPUP */
447 }
448 SHOW(" TaskName\n");
449}
这是这个函数的调用关系图:

◆ TaskPendingReasonInfoGet()

STATIC VOID TaskPendingReasonInfoGet ( const LosTaskCB taskCB,
CHAR pendReason,
UINT32  maxLen,
UINTPTR lockID 
)

在文件 task_shellcmd.c398 行定义.

399{
400 CHAR *reason = NULL;
401
402 if (!(taskCB->taskStatus & OS_TASK_STATUS_PENDING)) {
403 reason = (CHAR *)ConvertTaskStatusToString(taskCB->taskStatus);
404 goto EXIT;
405 }
406
407 reason = CheckTaskWaitFlag(taskCB, lockID);
408 if (reason == NULL) {
409 reason = "Others";
410 }
411
412 if (taskCB->taskMux != NULL) {
413 *lockID = (UINTPTR)taskCB->taskMux;
414 LosTaskCB *owner = ((LosMux *)taskCB->taskMux)->owner;
415 if (owner != NULL) {
416 if (snprintf_s(pendReason, maxLen, maxLen - 1, "Mutex-%u", owner->taskID) == EOK) {
417 return;
418 }
419 }
420 }
421
422EXIT:
423 if (strcpy_s(pendReason, maxLen, reason) != EOK) {
424 PRINT_ERR("Get pend reason copy failed !\n");
425 }
426}
Definition: los_mux.h:73
VOID * taskMux
STATIC CHAR * CheckTaskWaitFlag(const LosTaskCB *taskCB, UINTPTR *lockID)
函数调用图:
这是这个函数的调用关系图:

◆ TaskWaterLineGet()

STATIC VOID TaskWaterLineGet ( UINTPTR  waterLineBase,
LosTaskCB tcbArray 
)

在文件 task_shellcmd.c340 行定义.

341{
342 UINT32 intSave;
343 UINT32 *taskWaterLine = (UINT32 *)waterLineBase;
344
345 for (UINT32 tid = 0; tid < g_taskMaxNum; ++tid) {
346 const LosTaskCB *taskCB = g_taskCBArray + tid;
347 SCHEDULER_LOCK(intSave);
348 if (OsTaskIsUnused(taskCB)) {
349 SCHEDULER_UNLOCK(intSave);
350 tcbArray[tid].taskStatus = OS_TASK_STATUS_UNUSED;
351 continue;
352 }
353
354 (VOID)OsStackWaterLineGet((const UINTPTR *)((UINTPTR)taskCB->topOfStack + taskCB->stackSize),
355 (const UINTPTR *)taskCB->topOfStack, &taskWaterLine[taskCB->taskID]);
356 SCHEDULER_UNLOCK(intSave);
357 }
358}
UINT32 OsStackWaterLineGet(const UINTPTR *stackBottom, const UINTPTR *stackTop, UINT32 *peakUsed)
Get stack waterline.
Definition: los_stackinfo.c:70
UINT32 taskID
函数调用图:
这是这个函数的调用关系图: