Catching a process before it sleeps on file IO?

Nat Lanza (magus@cs.cmu.edu)
10 Dec 1999 00:37:00 -0500


I'd like to be able to catch certain processes just before they sleep
on file IO. Ideally, I could catch only those sleeping on read calls,
but catching everything and being able to sort out what's happening in
my handler would be okay too.

Basically, I have a process flag (call it PF_MONKEY for now), and I'd
like to call monkey_about_to_sleep() when a process with PF_MONKEY set
goes to sleep waiting for a file read to complete.

I've thought about trawling through the fs and block code and tagging
all the 'current->state = TASK_UNINTERRUPTIBLE; schedule()' cases, but
that seems both error-prone and hideously ugly. Really, the individual
filesystem and device drivers shouldn't have to care about PF_MONKEY
processes. Is there a better way?

Can I, for example, figure out _why_ 'current' has gone from
TASK_RUNNING to TASK_UNINTERRUPTIBLE inside of schedule()?

I'm looking through 2.3.32pre2, btw.

Thanks.

--nat

-- 
nat lanza --------------------- research programmer, parallel data lab, cmu scs
magus@cs.cmu.edu -------------------------------- http://www.cs.cmu.edu/~magus/
there are no whole truths; all truths are half-truths -- alfred north whitehead

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/