你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

FREERTOS 的列表问题?

[复制链接]
annQian 提问时间:2018-11-29 17:14 /
void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem )
{
   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(). */
pxNewListItem->pxNext = pxIndex;
pxNewListItem->pxPrevious = pxIndex->pxPrevious;
pxIndex->pxPrevious->pxNext = pxNewListItem;
pxIndex->pxPrevious = pxNewListItem;
/* Remember which list the item is in. */
pxNewListItem->pvContainer = ( void * ) pxList;
( pxList->uxNumberOfItems )++;
}
pxList->pxIndex 这个指针为啥在插入新变量之后不更新?函数结尾处,它应该指向新添加的变量吧。
void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem )
{
ListItem_t *pxIterator;
const uint xValueOfInsertion = pxNewListItem->xItemValue;

/* Insert the new list item into the list, sorted in xItemValue order.
If the list already contains a list item with the same item value then the
new list item should be placed after it.  This ensures that TCB's which are
stored in ready lists (all of which have the same xItemValue value) get a
share of the CPU.  However, if the xItemValue is the same as the back marker
the iteration loop below will not end.  Therefore the value is checked
first, and the algorithm slightly modified if necessary. */
if( xValueOfInsertion == 0xFFFFFFFF )
{
  pxIterator = pxList->xListEnd.pxPrevious;
  
}
else
{
  
  for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM.  This is checked and valid. */
  {
   /* There is nothing to do here, just iterating to the wanted
   insertion position. */
  }
}
pxNewListItem->pxNext = pxIterator->pxNext;
pxNewListItem->pxNext->pxPrevious = pxNewListItem;
pxNewListItem->pxPrevious = pxIterator;
pxIterator->pxNext = pxNewListItem;
/* Remember which list the item is in.  This allows fast removal of the
item later. */
pxNewListItem->pvContainer = ( void * ) pxList;
( pxList->uxNumberOfItems )++;
}
这个函数中pxNext 指针的值也没更新
uint uxListRemove( ListItem_t * const pxItemToRemove )
{

/* The list item knows which list it is in.  Obtain the list from the list
item. */
  List_t * const pxList = ( List_t * ) pxItemToRemove->pvContainer;

pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;
pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext;
/* Make sure the index is left pointing to a valid item. */
if( pxList->pxIndex == pxItemToRemove )
{
  pxList->pxIndex = pxItemToRemove->pxPrevious;
}
else
{
  
}
pxItemToRemove->pvContainer = NULL;
( pxList->uxNumberOfItems )--;
return pxList->uxNumberOfItems;
}

只有删除函数中pxNext 指针更新了,这样是不是逻辑不严密呀?
望指点

评分

参与人数 1 ST金币 +20 收起 理由
STMCU + 20 活动奖励

查看全部评分

收藏 1 评论0 发布时间:2018-11-29 17:14

举报

0个回答

所属标签

相似问题

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版