networking driver implementation question

norume at young.usask.ca norume at young.usask.ca
Wed Oct 17 00:54:01 UTC 2001


Quoting Till Straumann <strauman at SLAC.Stanford.EDU>:

> Hi.
> 
> I am porting Donald Beckers linux driver for the yellowfin/Symbios
> 53C885
> to RTEMS.
> 
> When I look at the ethernet drivers in 'libchip' I can see that a
> common
> 
> scheme is to create driver tasks. The TX task doing something like
> 
> for (;;) {
>    wait_on_event();
>    IF_DEQUEUE(&ifp->if_snd, m);
>    sendpacket(m);
> }
> 
> Note that this loop is running in the context of the network _driver's_
> task.
> 
> A close look at IF_DEQUEUE() [which normally is only used in the
> context
> 
> of the BSD networking task] reveals that the queue data structure is
> not
> 
> protected by any kind of mutex.
> 
> Can somebody explain how the queue is protected from being corrupted
> (other than by good karma)??
> 

An RTEMS task must hold the network mutex when active in the BSD kernel-related code.  This preserves the semantics of the BSD kernel operation (no context switches when running in kernel mode).

You'll note that the `wait_on_event' you mentioned above is actually a call to rtems_bsdnet_event_receive (as opposed to a simple rtems_event_receive).  The rtems_bsdnet_event_receive routine unlocks the network mutex, waits for the event (or events), locks the mutex, and returns.

For a full description of this, see the Networking addition to the RTEMS User guide.



More information about the users mailing list