Re: [LARTC] what's the meaning of xchg()?

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>    I find a line in tbf_change() in sch_tbf.c: ptab = xchg(&q->P_tab, ptab);
>
>        Can I consider that the pointers are exchanged between q->P_tab and ptab? as following:
>
>        	prev=q->R_tab;
>     	q->R_tab =  rtab;
> 	    rtab = prev;
>
>         Is my understanding righ?

Yes almost. old = xchg(ptv,v) does old=*ptr; *ptr=v and does
it atomicaly (!) thus no locking is needed.
devik



[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux