vxWorks中arpFlush代码中存在竞争,导致调用任务挂起

2746阅读 4评论2011-11-30 areece
分类:系统运维

一个客户的发现我们的设备上出现了arpFlush处挂起的现象,看了一下代码,发现arpFlush中存在竞争条件,即代码中获取arp_llinfo链表信息时,没有处于spnet之下,所以会导致原本有效的链表节点,在进入spnet保护的临界区之后,实际上可能被其它任务释放,从而导致任务挂起。代码如下,出问题的就是第一行代码。

  1. void arpFlush (void)
  2.     {
  3.     struct llinfo_arp * la = arp_llinfo.lh_first;
  4.     struct llinfo_arp * ola;
  5.     struct rtentry *rt;
  6.     int    s;

  7.     s = splnet ();

  8.     while ((ola = la) != 0)
  9.     {
  10.         rt = la->la_rt;
  11.     la = la->la_le.le_next;

  12.     /* if entry permanent */
  13.     if ((rt->rt_rmx.rmx_expire == 0) || (rt->rt_flags == 0))
  14.      continue;

  15.     arptfree(ola); /* timer has expired; clear */
  16.     }

  17.     splx (s);
  18.     }
上一篇:历史由谁创造
下一篇:只有死亡与交税才是永恒

文章评论