freertos双向链表的插入

uxTopReadyPriority = uxTopReadyPriority | (1UL<<pxNewTCB->uxPriority);

//listINSERT_END( &pxReadyTasksLists[pxNewTCB->uxPriority], &pxNewTCB->xStateListItem );

List_t *pxList_; //指向目标优先级的就绪任务列表 (通过TCB的优先级索引)

ListItem_t *pxListItem_; //是待插入的任务状态列表项 (来自TCB的xStateListItem)

pxList_ = &pxReadyTasksLists[pxNewTCB->uxPriority];

pxListItem_ = &pxNewTCB->xStateListItem;

ListItem_t * const pxIndex = pxList_->pxIndex; //是列表的遍历指针 (通常指向列表末尾)

/* Insert a new list item into ( pxList ), but rather than sort the list,

* makes the new list item the last item to be removed by a call to

* listGET_OWNER_OF_NEXT_ENTRY(). */

pxListItem_->pxNext = pxIndex; // 新项的next指向当前索引项

pxListItem_->pxPrevious = pxIndex->pxPrevious; // 新项的prev指向索引项的前驱

pxIndex->pxPrevious->pxNext = pxListItem_; // 前驱项的next指向新项

pxIndex->pxPrevious = pxListItem_; // 索引项的prev指向新项

//Remember which list the item is in.

pxListItem_->pxContainer = pxList_; //记录所属列表 (用于后续从列表移除)

pxList_->uxNumberOfItems++; //更新列表长度计数器

portSETUP_TCB(pxNewTCB);

// [原有节点] ↔ [pxIndex节点]

//形成环形链表结构:[原有节点] ↔ [新节点] ↔ [pxIndex节点]

// volatile UBaseType_t uxNumberOfItems = 0 //链表中元素的个数

// |<---- ListItem_t *pxIndex; //总是指向xListEnd节点,在链表尾部插入的时候,方便找到位置

//|-->|----> TickType_t xItemValue = portMAX_DELAY [MiniListItem_t xListEnd]

//|<-------- struct xLIST_ITEM *pxNext; //后继节点

//|<-------- struct xLIST_ITEM *pxPrevious; //前驱节点

//|------->volatile UBaseType_t uxNumberOfItems = 1 //链表中元素的个数

//| |<-----ListItem_t *pxIndex; //总是指向xListEnd节点,在链表尾部插入的时候,方便找到位置

//| |->|-->TickType_t xItemValue = portMAX_DELAY [MiniListItem_t xListEnd]

//| | struct xLIST_ITEM *pxNext; ----->| //后继节点

//| | struct xLIST_ITEM *pxPrevious; ----->| //前驱节点

//| | |

//| | TickType_t xItemValue; <-------------| //链表节点的值

//| |<--struct xLIST_ITEM *pxNext; //后继节点

//| |<--struct xLIST_ITEM *pxPrevious; //前驱节点

//| void * pvOwner; //保存私有数据

//|<------ struct xLIST *pxContainer; //节点所在的链表

//|------->volatile UBaseType_t uxNumberOfItems = 2 //链表中元素的个数

//| |<-----ListItem_t *pxIndex; //总是指向xListEnd节点,在链表尾部插入的时候,方便找到位置

//| |->|-->TickType_t xItemValue = portMAX_DELAY [MiniListItem_t xListEnd]

//| | struct xLIST_ITEM *pxNext; ---->| //后继节点

//| | struct xLIST_ITEM *pxPrevious;--|----->| //前驱节点

//| | | |

//| |-|-->TickType_t xItemValue; <--------| | //链表节点的值

//| | | struct xLIST_ITEM *pxNext; ----------->| //后继节点

//| | |<--struct xLIST_ITEM *pxPrevious; | //前驱节点

//| | | void * pvOwner; | //保存私有数据

//|<-|-|---struct xLIST *pxContainer; | //节点所在的链表

//| | | |

//| | | TickType_t xItemValue; <-------------| //链表节点的值

//| | |<--struct xLIST_ITEM *pxNext; //后继节点

//| |<----struct xLIST_ITEM *pxPrevious; //前驱节点

//| void * pvOwner; //保存私有数据

//|<------ struct xLIST *pxContainer; //节点所在的链表

相关推荐
天选之女wow15 小时前
【代码随想录算法训练营——Day4】链表——24.两两交换链表中的节点、19.删除链表的倒数第N个节点、面试题02.07.链表相交、142.环形链表II
数据结构·算法·leetcode·链表
胡萝卜3.015 小时前
数据结构初阶:树的相关性质总结
数据结构·二叉树·性质·二叉树的性质
KarrySmile15 小时前
Day12--HOT100--23. 合并 K 个升序链表,146. LRU 缓存,94. 二叉树的中序遍历
数据结构·链表·二叉树·递归·hot100·lru·灵茶山艾府
Miraitowa_cheems21 小时前
LeetCode算法日记 - Day 34: 二进制求和、字符串相乘
java·算法·leetcode·链表·职场和发展
今后12321 小时前
【数据结构】带哨兵位双向循环链表
数据结构·链表
Lee嘉图21 小时前
数据结构——队列(Java)
数据结构
梁辰兴1 天前
数据结构:查找
数据结构·算法·查找·顺序查找·折半查找·分块查找
midsummer_woo1 天前
#数据结构----2.1线性表
数据结构
ShineWinsu1 天前
对于单链表相关经典算法题:206. 反转链表及876. 链表的中间结点的解析
java·c语言·数据结构·学习·算法·链表·力扣