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

相关推荐
sin_hielo4 小时前
leetcode 2483
数据结构·算法·leetcode
大头流矢5 小时前
归并排序与计数排序详解
数据结构·算法·排序算法
一路往蓝-Anbo5 小时前
【第20期】延时的艺术:HAL_Delay vs vTaskDelay
c语言·数据结构·stm32·单片机·嵌入式硬件
梭七y11 小时前
【力扣hot100题】(103)移动零
数据结构·算法·leetcode
H CHY12 小时前
C++代码
c语言·开发语言·数据结构·c++·算法·青少年编程
xiaolang_8616_wjl12 小时前
c++题目_传桶(改编于atcoder(题目:Heavy Buckets))
数据结构·c++·算法
历程里程碑15 小时前
双指针巧解LeetCode接雨水难题
java·开发语言·数据结构·c++·python·flask·排序算法
橘颂TA16 小时前
【剑斩OFFER】算法的暴力美学——链表相加(二)
数据结构·链表·牛客·结构与算法
报错小能手16 小时前
数据结构 可扩展哈希
数据结构·哈希算法·散列表
AI科技星16 小时前
宇宙的像素:真空中一点如何编码无限星光
数据结构·人工智能·算法·机器学习·重构