Re: Using ifnet pointers safely
Re: Using ifnet pointers safely
- Subject: Re: Using ifnet pointers safely
- From: Michael Cashwell <email@hidden>
- Date: Fri, 25 Oct 2002 10:52:44 -0400
On Friday, October 25, 2002, at 05:03 AM, Stiphane Sudre wrote:
On Friday, October 25, 2002, at 02:17 AM, Michael Cashwell wrote:
And lastly, whatever the solution to that is ("kernel threads can't be
preempted" or "use splnet() / splx()", or something else)...
If I remember correctly what I saw in xnu, splnet and splx are just
doing nothing.
I haven't looked up their source but I also recall statements that they
are not sufficient for synchronization on MP systems. I think they
represent some sort of interrupt disable which only applies to the one
CPU executing them. Or something like that...
But that's using them by themselves. I'm wondering if they might help
_if_ one also holds the network funnel. In that case as long as I don't
actively block perhaps splnet()/splx() would prevent preemption long
enough to finish iterating the interface list. (I could also modify my
thread's quantum to achieve the same thing I guess.)
But that sounds bad. It's using a sledge hammer to swat a fly. I only
care about other threads modifying the interface list. Blocking them
all just to protect that one data structure seems heavy handed and is
not being a good citizen.
What I would like is a mutex (or even better a read lock) I could take
that would protect the "ifnet.tqh_first; ...if_link.tqe_next interface
linked list (like the funnel) but that would not be taken from me if I
blocked or was preempted.
It seems to me that many of the kernel's data structures would have
this peril and yet it works. I must be missing something fundamental.
Any ideas would be appreciated.
Mike
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.