Merge pull request '文豪合并' (#16) from wenhao_branch into master

master
p2gpamesw 10 months ago
commit 651fc40a4f

Binary file not shown.

@ -38,16 +38,17 @@
#if __cplusplus #if __cplusplus
extern "C" { extern "C" {
#endif #endif
#endif /* __cplusplus */ #endif /* __cplusplus */nbb
typedef struct { typedef struct {
LOS_DL_LIST muxListHead; /* Task-held mutexs list */ LOS_DL_LIST muxListHead; /* Task-held mutexs list */ //用于管理任务持有的互斥锁列表//
UINT64 lastAccessTime; /* The last operation time */ UINT64 lastAccessTime; /* The last operation time */ //记录最后一次操作的时间//
} MuxDLinkCB; } MuxDLinkCB;
/*管理任务持有的互斥锁列表和跟踪死锁情况*/
typedef struct { typedef struct {
LOS_DL_LIST muxList; /* Insert mutex into the owner task CB */ LOS_DL_LIST muxList; /* Insert mutex into the owner task CB */ //用于将互斥锁插入到所属任务的控制块中//
VOID *muxCB; /* The Mutex CB pointer */ VOID *muxCB; /* The Mutex CB pointer */ //指向互斥锁控制块的指针//
} MuxDLinkNode; } MuxDLinkNode;
STATIC MuxDLinkCB *g_muxDeadlockCBArray = NULL; STATIC MuxDLinkCB *g_muxDeadlockCBArray = NULL;
@ -57,9 +58,9 @@ STATIC MuxDLinkCB *g_muxDeadlockCBArray = NULL;
* that has not been scheduled within this time. * that has not been scheduled within this time.
* The unit is tick. * The unit is tick.
*/ */
#define OS_MUX_DEADLOCK_CHECK_THRESHOLD 60000 #define OS_MUX_DEADLOCK_CHECK_THRESHOLD 60000 //定义两次检查互斥锁死锁之间的最小时间间隔,单位为毫秒//
UINT32 OsMuxDlockCheckInit(VOID) UINT32 OsMuxDlockCheckInit(VOID) //用于分配内存并初始化互斥锁控制块列表//
{ {
UINT32 index; UINT32 index;
UINT32 size = (LOSCFG_BASE_CORE_TSK_LIMIT + 1) * sizeof(MuxDLinkCB); UINT32 size = (LOSCFG_BASE_CORE_TSK_LIMIT + 1) * sizeof(MuxDLinkCB);
@ -78,7 +79,7 @@ UINT32 OsMuxDlockCheckInit(VOID)
return LOS_OK; return LOS_OK;
} }
VOID OsMuxDlockNodeInsert(UINT32 taskId, VOID *muxCB) VOID OsMuxDlockNodeInsert(UINT32 taskId, VOID *muxCB) //用于向指定任务的互斥锁链表中插入一个互斥锁节点//
{ {
MuxDLinkNode *muxDLNode = NULL; MuxDLinkNode *muxDLNode = NULL;
@ -96,7 +97,7 @@ VOID OsMuxDlockNodeInsert(UINT32 taskId, VOID *muxCB)
LOS_ListTailInsert(&g_muxDeadlockCBArray[taskId].muxListHead, &muxDLNode->muxList); LOS_ListTailInsert(&g_muxDeadlockCBArray[taskId].muxListHead, &muxDLNode->muxList);
} }
VOID OsMuxDlockNodeDelete(UINT32 taskId, const VOID *muxCB) VOID OsMuxDlockNodeDelete(UINT32 taskId, const VOID *muxCB) //用于从指定任务的互斥锁链表中删除指定的互斥锁节点//
{ {
MuxDLinkCB *muxDLCB = NULL; MuxDLinkCB *muxDLCB = NULL;
LOS_DL_LIST *list = NULL; LOS_DL_LIST *list = NULL;
@ -117,7 +118,7 @@ VOID OsMuxDlockNodeDelete(UINT32 taskId, const VOID *muxCB)
} }
} }
VOID OsTaskTimeUpdate(UINT32 taskId, UINT64 tickCount) VOID OsTaskTimeUpdate(UINT32 taskId, UINT64 tickCount) //用于更新任务的最后访问时间//
{ {
if (taskId > LOSCFG_BASE_CORE_TSK_LIMIT) { if (taskId > LOSCFG_BASE_CORE_TSK_LIMIT) {
return; return;
@ -126,7 +127,7 @@ VOID OsTaskTimeUpdate(UINT32 taskId, UINT64 tickCount)
g_muxDeadlockCBArray[taskId].lastAccessTime = tickCount; g_muxDeadlockCBArray[taskId].lastAccessTime = tickCount;
} }
STATIC VOID OsDeadlockBackTrace(const LosTaskCB *taskCB) STATIC VOID OsDeadlockBackTrace(const LosTaskCB *taskCB) //用于打印任务的函数调用栈信息//
{ {
TaskContext *context = NULL; TaskContext *context = NULL;
@ -137,7 +138,7 @@ STATIC VOID OsDeadlockBackTrace(const LosTaskCB *taskCB)
return; return;
} }
STATIC VOID OsMutexPendTaskList(LOS_DL_LIST *list) STATIC VOID OsMutexPendTaskList(LOS_DL_LIST *list) //用于打印互斥锁等待任务的列表信息//
{ {
LOS_DL_LIST *listTmp = NULL; LOS_DL_LIST *listTmp = NULL;
LosTaskCB *pendedTask = NULL; LosTaskCB *pendedTask = NULL;
@ -168,7 +169,7 @@ STATIC VOID OsMutexPendTaskList(LOS_DL_LIST *list)
SCHEDULER_UNLOCK(intSave); SCHEDULER_UNLOCK(intSave);
} }
STATIC VOID OsTaskHoldMutexList(MuxDLinkCB *muxDLCB) STATIC VOID OsTaskHoldMutexList(MuxDLinkCB *muxDLCB) //用于打印任务持有的互斥锁的信息//
{ {
UINT32 index = 0; UINT32 index = 0;
MuxDLinkNode *muxDLNode = NULL; MuxDLinkNode *muxDLNode = NULL;
@ -204,7 +205,7 @@ STATIC VOID OsTaskHoldMutexList(MuxDLinkCB *muxDLCB)
} }
} }
VOID OsMutexDlockCheck(VOID) VOID OsMutexDlockCheck(VOID) //用于检测互斥锁死锁情况并输出相关信息//
{ {
UINT32 loop, intSave; UINT32 loop, intSave;
UINT32 taskId; UINT32 taskId;
@ -234,7 +235,7 @@ VOID OsMutexDlockCheck(VOID)
SCHEDULER_UNLOCK(intSave); SCHEDULER_UNLOCK(intSave);
} }
#ifdef LOSCFG_SHELL #ifdef LOSCFG_SHELL //用于在命令行中执行互斥锁死锁检查并输出相关信息//
UINT32 OsShellCmdMuxDeadlockCheck(UINT32 argc, const CHAR **argv) UINT32 OsShellCmdMuxDeadlockCheck(UINT32 argc, const CHAR **argv)
{ {
if (argc > 0) { if (argc > 0) {

@ -41,20 +41,21 @@ extern "C" {
#endif #endif
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifdef LOSCFG_DEBUG_MUTEX #ifdef LOSCFG_DEBUG_MUTEX //用于表示互斥锁的调试信息//
typedef struct { typedef struct {
TSK_ENTRY_FUNC creator; /* The task entry who created this mutex */ TSK_ENTRY_FUNC creator; /* The task entry who created this mutex */
UINT64 lastAccessTime; /* The last access time */ UINT64 lastAccessTime; /* The last access time */
} MuxDebugCB; } MuxDebugCB;
STATIC MuxDebugCB *g_muxDebugArray = NULL; STATIC MuxDebugCB *g_muxDebugArray = NULL;
//用于比较两个互斥锁调试信息的最后访问时间//
STATIC BOOL MuxCompareValue(const SortParam *sortParam, UINT32 left, UINT32 right) STATIC BOOL MuxCompareValue(const SortParam *sortParam, UINT32 left, UINT32 right)
{ {
return (*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, left)) > return (*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, left)) >
*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, right))); *((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, right)));
} }
UINT32 OsMuxDbgInit(VOID) UINT32 OsMuxDbgInit(VOID) //用于初始化互斥锁调试信息数组//
{ {
UINT32 size = LOSCFG_BASE_IPC_MUX_LIMIT * sizeof(MuxDebugCB); UINT32 size = LOSCFG_BASE_IPC_MUX_LIMIT * sizeof(MuxDebugCB);
/* system resident memory, don't free */ /* system resident memory, don't free */
@ -67,19 +68,20 @@ UINT32 OsMuxDbgInit(VOID)
return LOS_OK; return LOS_OK;
} }
VOID OsMuxDbgTimeUpdate(UINT32 muxId) VOID OsMuxDbgTimeUpdate(UINT32 muxId) //用于更新指定互斥锁的最后访问时间//
{ {
MuxDebugCB *muxDebug = &g_muxDebugArray[GET_MUX_INDEX(muxId)]; MuxDebugCB *muxDebug = &g_muxDebugArray[GET_MUX_INDEX(muxId)];
muxDebug->lastAccessTime = LOS_TickCountGet(); muxDebug->lastAccessTime = LOS_TickCountGet();
} }
VOID OsMuxDbgUpdate(UINT32 muxId, TSK_ENTRY_FUNC creator) VOID OsMuxDbgUpdate(UINT32 muxId, TSK_ENTRY_FUNC creator) //用于更新指定互斥锁的创建者和最后访问时间//
{ {
MuxDebugCB *muxDebug = &g_muxDebugArray[GET_MUX_INDEX(muxId)]; MuxDebugCB *muxDebug = &g_muxDebugArray[GET_MUX_INDEX(muxId)];
muxDebug->creator = creator; muxDebug->creator = creator;
muxDebug->lastAccessTime = LOS_TickCountGet(); muxDebug->lastAccessTime = LOS_TickCountGet();
} }
//用于对互斥锁索引数组进行排序,并检查可能存在的互斥锁泄漏//
STATIC VOID SortMuxIndexArray(UINT32 *indexArray, UINT32 count) STATIC VOID SortMuxIndexArray(UINT32 *indexArray, UINT32 count)
{ {
LosMuxCB muxNode = {{0, 0}, 0, 0, 0, 0}; LosMuxCB muxNode = {{0, 0}, 0, 0, 0, 0};
@ -119,7 +121,7 @@ STATIC VOID SortMuxIndexArray(UINT32 *indexArray, UINT32 count)
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, indexArray); (VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, indexArray);
} }
VOID OsMutexCheck(VOID) VOID OsMutexCheck(VOID) //用于检查互斥锁的状态并对可能存在的互斥锁泄漏进行处理//
{ {
LosMuxCB muxNode = {{0, 0}, 0, 0, 0, 0}; LosMuxCB muxNode = {{0, 0}, 0, 0, 0, 0};
MuxDebugCB muxDebugNode = {0}; MuxDebugCB muxDebugNode = {0};
@ -165,6 +167,7 @@ VOID OsMutexCheck(VOID)
} }
#ifdef LOSCFG_SHELL #ifdef LOSCFG_SHELL
//用于获取互斥锁信息//
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdMuxInfoGet(UINT32 argc, const CHAR **argv) LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdMuxInfoGet(UINT32 argc, const CHAR **argv)
{ {
if (argc > 0) { if (argc > 0) {

@ -38,20 +38,21 @@ extern "C" {
#endif #endif
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifdef LOSCFG_DEBUG_QUEUE #ifdef LOSCFG_DEBUG_QUEUE //用于保存队列的调试信息//
typedef struct { typedef struct {
TSK_ENTRY_FUNC creator; /* The task entry who created this queue */ TSK_ENTRY_FUNC creator; /* The task entry who created this queue */
UINT64 lastAccessTime; /* The last access time */ UINT64 lastAccessTime; /* The last access time */
} QueueDebugCB; } QueueDebugCB;
STATIC QueueDebugCB *g_queueDebugArray = NULL; STATIC QueueDebugCB *g_queueDebugArray = NULL;
//用于比较队列中的元素值//
STATIC BOOL QueueCompareValue(const SortParam *sortParam, UINT32 left, UINT32 right) STATIC BOOL QueueCompareValue(const SortParam *sortParam, UINT32 left, UINT32 right)
{ {
return (*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, left)) > return (*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, left)) >
*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, right))); *((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, right)));
} }
UINT32 OsQueueDbgInit(VOID) UINT32 OsQueueDbgInit(VOID) //用于初始化队列的调试信息//
{ {
UINT32 size = LOSCFG_BASE_IPC_QUEUE_LIMIT * sizeof(QueueDebugCB); UINT32 size = LOSCFG_BASE_IPC_QUEUE_LIMIT * sizeof(QueueDebugCB);
@ -65,14 +66,14 @@ UINT32 OsQueueDbgInit(VOID)
return LOS_OK; return LOS_OK;
} }
VOID OsQueueDbgTimeUpdate(UINT32 queueId) VOID OsQueueDbgTimeUpdate(UINT32 queueId) //用于更新队列的最后访问时间//
{ {
QueueDebugCB *queueDebug = &g_queueDebugArray[GET_QUEUE_INDEX(queueId)]; QueueDebugCB *queueDebug = &g_queueDebugArray[GET_QUEUE_INDEX(queueId)];
queueDebug->lastAccessTime = LOS_TickCountGet(); queueDebug->lastAccessTime = LOS_TickCountGet();
return; return;
} }
VOID OsQueueDbgUpdate(UINT32 queueId, TSK_ENTRY_FUNC entry) VOID OsQueueDbgUpdate(UINT32 queueId, TSK_ENTRY_FUNC entry) //用于更新队列的调试信息//
{ {
QueueDebugCB *queueDebug = &g_queueDebugArray[GET_QUEUE_INDEX(queueId)]; QueueDebugCB *queueDebug = &g_queueDebugArray[GET_QUEUE_INDEX(queueId)];
queueDebug->creator = entry; queueDebug->creator = entry;
@ -80,7 +81,7 @@ VOID OsQueueDbgUpdate(UINT32 queueId, TSK_ENTRY_FUNC entry)
return; return;
} }
STATIC INLINE VOID OsQueueInfoOutPut(const LosQueueCB *node) STATIC INLINE VOID OsQueueInfoOutPut(const LosQueueCB *node) //用于输出队列的信息//
{ {
PRINTK("Queue ID <0x%x> may leak, queue len is 0x%x, " PRINTK("Queue ID <0x%x> may leak, queue len is 0x%x, "
"readable cnt:0x%x, writeable cnt:0x%x, ", "readable cnt:0x%x, writeable cnt:0x%x, ",
@ -90,13 +91,13 @@ STATIC INLINE VOID OsQueueInfoOutPut(const LosQueueCB *node)
node->readWriteableCnt[OS_QUEUE_WRITE]); node->readWriteableCnt[OS_QUEUE_WRITE]);
} }
STATIC INLINE VOID OsQueueOpsOutput(const QueueDebugCB *node) STATIC INLINE VOID OsQueueOpsOutput(const QueueDebugCB *node) //用于输出队列操作的信息//
{ {
PRINTK("TaskEntry of creator:0x%p, Latest operation time: 0x%llx\n", PRINTK("TaskEntry of creator:0x%p, Latest operation time: 0x%llx\n",
node->creator, node->lastAccessTime); node->creator, node->lastAccessTime);
} }
STATIC VOID SortQueueIndexArray(UINT32 *indexArray, UINT32 count) STATIC VOID SortQueueIndexArray(UINT32 *indexArray, UINT32 count) //用于对队列索引数组进行排序并输出相应的队列信息//
{ {
LosQueueCB queueNode = {0}; LosQueueCB queueNode = {0};
QueueDebugCB queueDebugNode = {0}; QueueDebugCB queueDebugNode = {0};
@ -128,7 +129,7 @@ STATIC VOID SortQueueIndexArray(UINT32 *indexArray, UINT32 count)
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, indexArray); (VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, indexArray);
} }
VOID OsQueueCheck(VOID) VOID OsQueueCheck(VOID) //用于检查队列的状态并输出相应信息//
{ {
LosQueueCB queueNode = {0}; LosQueueCB queueNode = {0};
QueueDebugCB queueDebugNode = {0}; QueueDebugCB queueDebugNode = {0};
@ -182,6 +183,7 @@ VOID OsQueueCheck(VOID)
} }
#ifdef LOSCFG_SHELL #ifdef LOSCFG_SHELL
//当用户输入 "queue" 命令时,会输出已使用队列的信息//
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdQueueInfoGet(UINT32 argc, const CHAR **argv) LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdQueueInfoGet(UINT32 argc, const CHAR **argv)
{ {
if (argc > 0) { if (argc > 0) {

@ -40,17 +40,17 @@ extern "C" {
#define DECIMAL_TO_PERCENTAGE 100 #define DECIMAL_TO_PERCENTAGE 100
typedef struct { typedef struct {
UINT64 idleRuntime; UINT64 idleRuntime; //空闲任务的运行时间//
UINT64 idleStarttime; UINT64 idleStarttime; //空闲任务的启动时间//
UINT64 highTaskRuntime; UINT64 highTaskRuntime; //高优先级任务的运行时间//
UINT64 highTaskStarttime; UINT64 highTaskStarttime; //高优先级任务的启动时间//
UINT64 sumPriority; UINT64 sumPriority; //任务优先级之和//
UINT32 prioritySwitch; UINT32 prioritySwitch; //任务切换次数//
UINT32 highTaskSwitch; UINT32 highTaskSwitch; //高优先级任务切换次数//
UINT32 contexSwitch; UINT32 contexSwitch; //上下文切换次数//
UINT32 hwiNum; UINT32 hwiNum; //硬件中断次数//
#ifdef LOSCFG_KERNEL_SMP #ifdef LOSCFG_KERNEL_SMP
UINT32 ipiIrqNum; UINT32 ipiIrqNum; //中断次数(仅在多核配置下定义)//
#endif #endif
} StatPercpu; } StatPercpu;
@ -58,6 +58,7 @@ STATIC BOOL g_statisticsStartFlag = FALSE;
STATIC UINT64 g_statisticsStartTime; STATIC UINT64 g_statisticsStartTime;
STATIC StatPercpu g_statPercpu[LOSCFG_KERNEL_CORE_NUM]; STATIC StatPercpu g_statPercpu[LOSCFG_KERNEL_CORE_NUM];
//用于在每个 CPU 核心上进行调度统计//
STATIC VOID OsSchedStatisticsPerCpu(const LosTaskCB *runTask, const LosTaskCB *newTask) STATIC VOID OsSchedStatisticsPerCpu(const LosTaskCB *runTask, const LosTaskCB *newTask)
{ {
UINT32 cpuId; UINT32 cpuId;
@ -106,6 +107,7 @@ STATIC VOID OsSchedStatisticsPerCpu(const LosTaskCB *runTask, const LosTaskCB *n
return; return;
} }
//用于更新调度统计信息//
LITE_OS_SEC_TEXT_MINOR VOID OsSchedStatistics(LosTaskCB *runTask, LosTaskCB *newTask) LITE_OS_SEC_TEXT_MINOR VOID OsSchedStatistics(LosTaskCB *runTask, LosTaskCB *newTask)
{ {
UINT64 runtime; UINT64 runtime;
@ -131,7 +133,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsSchedStatistics(LosTaskCB *runTask, LosTaskCB *new
OsSchedStatisticsPerCpu(runTask, newTask); OsSchedStatisticsPerCpu(runTask, newTask);
} }
LITE_OS_SEC_TEXT_MINOR VOID OsHwiStatistics(size_t intNum) LITE_OS_SEC_TEXT_MINOR VOID OsHwiStatistics(size_t intNum) //用于更新硬中断的统计信息//
{ {
UINT32 cpuId = ArchCurrCpuid(); UINT32 cpuId = ArchCurrCpuid();
@ -149,7 +151,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsHwiStatistics(size_t intNum)
return; return;
} }
LITE_OS_SEC_TEXT_MINOR VOID OsShellCmdDumpSched(VOID) LITE_OS_SEC_TEXT_MINOR VOID OsShellCmdDumpSched(VOID) //用于打印任务的调度统计信息//
{ {
LosTaskCB *taskCB = NULL; LosTaskCB *taskCB = NULL;
UINT32 loop; UINT32 loop;
@ -192,7 +194,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsShellCmdDumpSched(VOID)
PRINTK("\n"); PRINTK("\n");
} }
LITE_OS_SEC_TEXT_MINOR VOID OsStatisticsShow(UINT64 statisticsPastTime) LITE_OS_SEC_TEXT_MINOR VOID OsStatisticsShow(UINT64 statisticsPastTime) //用于显示系统的统计信息//
{ {
UINT32 cpuId; UINT32 cpuId;
PRINTK("\n"); PRINTK("\n");
@ -238,7 +240,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsStatisticsShow(UINT64 statisticsPastTime)
PRINTK("\n"); PRINTK("\n");
} }
LITE_OS_SEC_TEXT_MINOR VOID OsShellStatisticsStart(VOID) LITE_OS_SEC_TEXT_MINOR VOID OsShellStatisticsStart(VOID) //用于在多核系统中启动统计功能//
{ {
LosTaskCB *taskCB = NULL; LosTaskCB *taskCB = NULL;
UINT32 loop; UINT32 loop;
@ -285,6 +287,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsShellStatisticsStart(VOID)
return; return;
} }
//用于在多核系统中停止统计功能,并进行统计数据的处理和展示//
LITE_OS_SEC_TEXT_MINOR VOID OsShellStatisticsStop(VOID) LITE_OS_SEC_TEXT_MINOR VOID OsShellStatisticsStop(VOID)
{ {
LosTaskCB *taskCB = NULL; LosTaskCB *taskCB = NULL;

@ -44,7 +44,7 @@ extern "C" {
#ifdef LOSCFG_DEBUG_SEMAPHORE #ifdef LOSCFG_DEBUG_SEMAPHORE
#define OS_ALL_SEM_MASK 0xffffffff #define OS_ALL_SEM_MASK 0xffffffff
STATIC VOID OsSemPendedTaskNamePrint(LosSemCB *semNode) STATIC VOID OsSemPendedTaskNamePrint(LosSemCB *semNode) //用于打印等待某个信号量的任务列表//
{ {
LosTaskCB *tskCB = NULL; LosTaskCB *tskCB = NULL;
CHAR *nameArr[LOSCFG_BASE_CORE_TSK_LIMIT] = {0}; CHAR *nameArr[LOSCFG_BASE_CORE_TSK_LIMIT] = {0};
@ -76,20 +76,21 @@ STATIC VOID OsSemPendedTaskNamePrint(LosSemCB *semNode)
PRINTK("\n"); PRINTK("\n");
} }
typedef struct { typedef struct { //用于记录信号量的调试信息//
UINT16 origSemCount; /* Number of original available semaphores */ UINT16 origSemCount; /* Number of original available semaphores */
UINT64 lastAccessTime; /* The last operation time */ UINT64 lastAccessTime; /* The last operation time */
TSK_ENTRY_FUNC creator; /* The task entry who created this sem */ TSK_ENTRY_FUNC creator; /* The task entry who created this sem */
} SemDebugCB; } SemDebugCB;
STATIC SemDebugCB *g_semDebugArray = NULL; STATIC SemDebugCB *g_semDebugArray = NULL; //用于存储所有信号量的调试信息//
//用于比较两个排序元素的值//
STATIC BOOL SemCompareValue(const SortParam *sortParam, UINT32 left, UINT32 right) STATIC BOOL SemCompareValue(const SortParam *sortParam, UINT32 left, UINT32 right)
{ {
return (*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, left)) > return (*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, left)) >
*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, right))); *((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, right)));
} }
UINT32 OsSemDbgInit(VOID) UINT32 OsSemDbgInit(VOID) //用于初始化信号量的调试信息数组//
{ {
UINT32 size = LOSCFG_BASE_IPC_SEM_LIMIT * sizeof(SemDebugCB); UINT32 size = LOSCFG_BASE_IPC_SEM_LIMIT * sizeof(SemDebugCB);
/* system resident memory, don't free */ /* system resident memory, don't free */
@ -102,14 +103,14 @@ UINT32 OsSemDbgInit(VOID)
return LOS_OK; return LOS_OK;
} }
VOID OsSemDbgTimeUpdate(UINT32 semId) VOID OsSemDbgTimeUpdate(UINT32 semId) //用于更新指定信号量的最后一次访问时间//
{ {
SemDebugCB *semDebug = &g_semDebugArray[GET_SEM_INDEX(semId)]; SemDebugCB *semDebug = &g_semDebugArray[GET_SEM_INDEX(semId)];
semDebug->lastAccessTime = LOS_TickCountGet(); semDebug->lastAccessTime = LOS_TickCountGet();
return; return;
} }
VOID OsSemDbgUpdate(UINT32 semId, TSK_ENTRY_FUNC creator, UINT16 count) VOID OsSemDbgUpdate(UINT32 semId, TSK_ENTRY_FUNC creator, UINT16 count) //用于更新指定信号量的调试信息//
{ {
SemDebugCB *semDebug = &g_semDebugArray[GET_SEM_INDEX(semId)]; SemDebugCB *semDebug = &g_semDebugArray[GET_SEM_INDEX(semId)];
semDebug->creator = creator; semDebug->creator = creator;
@ -118,6 +119,8 @@ VOID OsSemDbgUpdate(UINT32 semId, TSK_ENTRY_FUNC creator, UINT16 count)
return; return;
} }
/*用于按照信号量的最后访问时间对当前正在使用的信号量进行排序,*/
/*并打印每个信号量的调试信息和等待该信号量的任务名*/
STATIC VOID OsSemSort(UINT32 *semIndexArray, UINT32 usedCount) STATIC VOID OsSemSort(UINT32 *semIndexArray, UINT32 usedCount)
{ {
UINT32 i, intSave; UINT32 i, intSave;
@ -154,7 +157,7 @@ STATIC VOID OsSemSort(UINT32 *semIndexArray, UINT32 usedCount)
} }
} }
} }
/*用于获取当前正在使用的信号量信息,并按照信号量的最后访问时间对信号量进行排序*/
UINT32 OsSemInfoGetFullData(VOID) UINT32 OsSemInfoGetFullData(VOID)
{ {
UINT32 usedSemCnt = 0; UINT32 usedSemCnt = 0;
@ -209,7 +212,7 @@ UINT32 OsSemInfoGetFullData(VOID)
} }
#ifdef LOSCFG_SHELL #ifdef LOSCFG_SHELL
STATIC UINT32 OsSemInfoOutput(size_t semId) STATIC UINT32 OsSemInfoOutput(size_t semId) //用于输出信号量信息//
{ {
UINT32 loop, semCnt, intSave; UINT32 loop, semCnt, intSave;
LosSemCB *semCB = NULL; LosSemCB *semCB = NULL;
@ -254,6 +257,7 @@ STATIC UINT32 OsSemInfoOutput(size_t semId)
return LOS_OK; return LOS_OK;
} }
//用于获取信号量信息//
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdSemInfoGet(UINT32 argc, const CHAR **argv) LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdSemInfoGet(UINT32 argc, const CHAR **argv)
{ {
size_t semId; size_t semId;

Loading…
Cancel
Save