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; //节点所在的链表

相关推荐
Han.miracle42 分钟前
数据结构——二叉树的从前序与中序遍历序列构造二叉树
java·数据结构·学习·算法·leetcode
独自破碎E3 小时前
判断链表是否为回文
数据结构·链表
liu****7 小时前
8.list的模拟实现
linux·数据结构·c++·算法·list
武帝为此9 小时前
【B树与B+树详解】
数据结构·b树
南莺莺9 小时前
邻接矩阵的基本操作
数据结构·算法··邻接矩阵
观望过往10 小时前
【Java数据结构】队列详解与经典 OJ 题目实战
java·数据结构
aramae11 小时前
详细分析平衡树--红黑树(万字长文/图文详解)
开发语言·数据结构·c++·笔记·算法
CHEN5_0211 小时前
【leetcode100】和为k的子数组(两种解法)
java·数据结构·算法
guguhaohao12 小时前
list,咕咕咕!
数据结构·c++·list
Code小翊13 小时前
希尔排序基础理解
数据结构·算法·排序算法