Re: wake up a wait queue when no one sleeps

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

 



On Tue, Mar 16, 2004 at 08:27:20 +0100, Franz Reinhardt wrote:
> Hi,
> 
> I just want to do the following:
> 
> From userspace I call
> 
> select()
> read()
> 
> The app normally blocks on the select call().
> 
> From kernelspace I have to code
> 
> an interrupt handler,
> a read(),
> a select() call.
> 
> Interrupt occurs, if new data is available, or if transmission is lost.
> 
> What should I do, when an interrupt occurs and the app's not doing a 
> select() ? Can I wake up a waitqueue if the application process is not 
> sleeping on it, and it will be woken when it calls the select ? Or does 
> the driver have to buffer the incoming data ?

There are two things to select. First, you need to provide the ->poll
method, that will tell, whether there are data ready. And then you need
to wake up the queue when they become ready (and it's safe to wake up
an empty queue -- just nothing happens).

So when there is a process sleeping in the select, it will be awoken by
the wake_up and the ->poll method will tell it, which descriptors
actualy have new data ready. Now when the process calls select and there
are already data ready, it first asks the ->poll method, whether there
are data ready. They are right away, so the process does not enther the
queue at all.

As to buffering, it can't be guaranteed, that the userland process will
get to calling read in a bound time (it might be preempted right after
returning from select and not get to CPU for a long time). So if the
hardware requires you to read the data in some time window, you will
need to read them from the interrupt, or it's bottom-half (perhaps using
DMA).

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

Attachment: signature.asc
Description: Digital signature


[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