Schedule within block request routines?

Kenneth Albanowski (kjahds@kjahds.com)
Mon, 1 Jun 1998 12:12:05 -0400 (EDT)


I'm writing a block device driver that, unfortunately, has to do some work
that may take some time, with no ability to drive the thing via interrupt,
or use timers (since the times involved are much smaller then jiffies.)

However, the task can be broken up into parts, and I was wondering whether
it is safe to invoke schedule() with a block device's request routine, to
give other tasks a chance to run. (I'm looking at the >=2.0.33 kernel
here.)

I've looked through the kernel drivers, and Rubini's book (Thanks,
Allesandro!), but both only appear to show exiting the request routine via
end_request(), or by return()'ing (with another task on a wait queue or
interrupt handler somewhere that will itself call end_request()). Is it
safe to invoke schedule() without immediately returning to the caller?

Specifically, in pseduo-code:

if (cmd == WRITE) {
unsigned long start = jiffies;
while (I'm-doing-the-thing-that-takes-a-while)
if (start != jiffies) {
schedule();
start = jiffies;
}
}

Thanks,
Ken

-- 
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu