tags:

views:

898

answers:

1

I have a kernel module that provides data to a userland process through read(). That process blocks on read until data becomes available. I achieve this through a wait_event_interruptible() in the read method.

Data comes from an interrupt handler, which sucks it into memory, then schedules a tasklet to process it. The original code schedules the tasklet, then calls wake_up_interruptible() to re-activate the blocked read. However, this causes a race condition as the tasklet may not be done processing the data before read tries to give it to the user process.

So the question is, is it safe to move my call to wake_up_interruptible() to the end of the tasklet?

+1  A: 

Yes, it is safe for a tasklet to call wake_up_interruptible() when it's done. See http://www.xml.com/ldd/chapter/book/ch09.html for an example.

FreeMemory