diff --git a/README.md b/README.md index cd8a3981887c665eb22506634b453a2491592453..dffd5b121a808b1ecfa00abb0458ff92e76b4d9d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ 系列篇文章查看: 进入>> 鸿蒙源码分析系列篇 [CSDN站](https://blog.csdn.net/kuangyufei) | [OSCHINA站](https://my.oschina.net/u/3751245) 查看, 正在持续更新中..., 感谢CSDN, OSCHINA 对博文的推荐. - 注释中文版查看: 进入>> 鸿蒙内核源码注释中文版 [CSDN仓库](https://codechina.csdn.net/kuangyufei/kernel_liteos_a_note) | [Gitee仓库 ](https://gitee.com/weharmony/kernel_liteos_a_note) | [Github仓库](https://github.com/kuangyufei/kernel_liteos_a_note) [coding仓库](https://weharmony.coding.net/public/harmony/kernel_liteos_a_note/git/files) 查看,四大仓库同步更新. 正在持续加注中.... + 注释中文版查看: 进入>> 鸿蒙内核源码注释中文版 [CSDN仓库](https://codechina.csdn.net/kuangyufei/kernel_liteos_a_note) | [Gitee仓库 ](https://gitee.com/weharmony/kernel_liteos_a_note) | [Github仓库](https://github.com/kuangyufei/kernel_liteos_a_note) | [Coding仓库](https://weharmony.coding.net/public/harmony/kernel_liteos_a_note/git/files) 查看,四大仓库同步更新. 正在持续加注中.... 精读内核源码当然是件很困难的事,但正因为很难才值得去做! 内心不渴望的永远不可能靠近自己.别再去纠结而没有行动.笔者一直坚信兴趣是最好的老师,加注就是在做自己感兴趣的事, 希望感兴趣的各位能看到.如果能让更多人参与到内核的研究,减少学习的成本,哪怕就节省一天的时间,这么多人能节省多少时间, 这是件多好玩,多有意义的事情啊. diff --git a/kernel/base/sched/sched_sq/los_priqueue.c b/kernel/base/sched/sched_sq/los_priqueue.c index 6d43ea17d4286bb48d7f1f287ebad27b90657aaf..2486345228489cdde185c874daf8334cf2ece25d 100644 --- a/kernel/base/sched/sched_sq/los_priqueue.c +++ b/kernel/base/sched/sched_sq/los_priqueue.c @@ -44,32 +44,32 @@ extern "C" { //*kfy 0x80000000U = 10000000000000000000000000000000(32个0) #define PRIQUEUE_PRIOR0_BIT 0x80000000U -LITE_OS_SEC_BSS LOS_DL_LIST *g_priQueueList = NULL; -LITE_OS_SEC_BSS UINT32 g_priQueueBitmap; - +LITE_OS_SEC_BSS LOS_DL_LIST *g_priQueueList = NULL;//队列链表 +LITE_OS_SEC_BSS UINT32 g_priQueueBitmap;//队列位图 +//内部队列初始化 UINT32 OsPriQueueInit(VOID) { UINT32 priority; - /* system resident resource */ - g_priQueueList = (LOS_DL_LIST *)LOS_MemAlloc(m_aucSysMem0, (OS_PRIORITY_QUEUE_NUM * sizeof(LOS_DL_LIST))); + /* system resident resource *///常驻内存 + g_priQueueList = (LOS_DL_LIST *)LOS_MemAlloc(m_aucSysMem0, (OS_PRIORITY_QUEUE_NUM * sizeof(LOS_DL_LIST)));//分配32个队列头节点 if (g_priQueueList == NULL) { return LOS_NOK; } for (priority = 0; priority < OS_PRIORITY_QUEUE_NUM; ++priority) { - LOS_ListInit(&g_priQueueList[priority]); + LOS_ListInit(&g_priQueueList[priority]);//队列初始化,前后指针指向自己 } return LOS_OK; } - +//获取位图中最高优先级对应链表的第一个节点 LOS_DL_LIST *OsPriQueueTop(LOS_DL_LIST *priQueueList, UINT32 *bitMap) { UINT32 priority; if (*bitMap != 0) { - priority = CLZ(*bitMap); - return LOS_DL_LIST_FIRST(&priQueueList[priority]); + priority = CLZ(*bitMap);//比如 bitmap = 0b00110101000 返回 4 ,意思是从右到左找到第一个出现1的索引位 + return LOS_DL_LIST_FIRST(&priQueueList[priority]);//取出第一个节点 } return NULL;