004.2-FreeRTOS202212-4005-将节点插入到链表的尾部


/*-----------------------------------------------------------*/

void vListInsertEnd(List_t *const pxList, ListItem_t *const pxNewListItem)
{
    	ListItem_t *const pxIndex = pxList->pxIndex;

    	/* Only effective when configASSERT() is also defined, these tests may catch the list data structures being overwritten in memory.  
		They will not catch data errors caused by incorrect configuration or use of FreeRTOS. */
	/*只有在还定义了configASSERT()时才有效,这些测试可能会捕获内存中被覆盖的链表数据结构。他们不会捕捉到由于不正确的配置或使用FreeRTOS而导致的数据错误*/

    	listTEST_LIST_INTEGRITY(pxList);
    	listTEST_LIST_ITEM_INTEGRITY(pxNewListItem);

    	/* 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(). */
	/*在pxList中插入一个新链表项,但不是对链表进行排序,而是通过调用listGET_OWNER_OF_NEXT_ENTRY()使新链表项成为最后一个要访问的项*/
    	pxNewListItem->pxNext = pxIndex;
    	pxNewListItem->pxPrevious = pxIndex->pxPrevious;

    	/* Only used during decision coverage testing. */
	/*仅在决策覆盖率测试期间使用*/
    	mtCOVERAGE_TEST_DELAY();

    	pxIndex->pxPrevious->pxNext = pxNewListItem;
    	pxIndex->pxPrevious = pxNewListItem;

    	/* Remember which list the item is in. */
	/*记住该节点所在的链表*/
    	pxNewListItem->pvContainer = (void *)pxList;

	/* 链表节点计数器++ */
    	(pxList->uxNumberOfItems)++;
}
/*-----------------------------------------------------------*/

FreeRTOS中将节点插入链表尾部 详细过程如下图 ,参考<[野火®]《FreeRTOS 内核实现与应用开发实战—基于STM32》>

  • 15
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值