Re: Wake up and sleep procedures for a function in a module

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

 



Hi,

On 4/29/05, Chandrakanth Chereddi <chereddi@xxxxxxxxx> wrote:
> This new module sit's on top of a device driver and intercepts all
> incoming packets. The module has a function, say "myTx()", which
> intercepts the packet, and after mangling the packet, add's it a queue
> "myQ". Another function does the actual "delivery" of the packet to
> the network driver, let's say this is "myDeliver()".
> 
> On receiving the first packet, myTx() has to add it to myQ, check if
> myDeliver() is "awake/active", if NOT, wake it up and return. Once
> myDeliver() is woken up, it iteratively delivers the packet to the
> actual driver until myQ is empty, and once done, it has to "sleep".
> Again at a later point, when myTx() has packet(s) to deliver, the
> above procedure repeats.
> 
> I wanted to know what might be the best way of performing the wakeup
> and sleep procedure, for the myDeliver() function.

Search through general OS literature for "producer-consumer" problem.
There are many options.

My first thought would be to use a semaphore, myTx would be upping it
after it has added an element to the work queue and myDeliver would
use down to wait for another item to arrive. Please note that you need
to protect queue manipulation with a separate lock as well so take
care of a potential deadlock.

HTH

Martin Jambor

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux