waiting and scheduling: is this OK?

Peter J. Braam (braam@cs.cmu.edu)
Sat, 20 Dec 1997 18:02:48 -0500 (EST)

The Coda filesystem passes requests to a user level cache manager and
waits for answers. I tried to imitate things like "soft" and "hard"
mounting from NFS but added a timeout for signals so that "short" calls
(like stat, which programs like to complete) will not normally be
interrupted in kernel mode.

When coda waits for a message it executes the routine below? Is this
OK? I am asking because the routines interruptible_sleep_on etc are much
more careful, but I don't understand the details there.

Thanks for any help!

- Peter -

(ps this is not in 2.1.73 yet, I'll send a patch tomorrow or so).

static inline void coda_waitfor_upcall(struct vmsg *vmp)
struct wait_queue wait = { current, NULL };

vmp->vm_posttime = jiffies;

add_wait_queue(&vmp->vm_sleep, &wait);
for (;;) {
if ( coda_hard == 0 )
current->state = TASK_INTERRUPTIBLE;
current->state = TASK_UNINTERRUPTIBLE;

if ( vmp->vm_flags & VM_WRITE )
if (signal_pending(current) &&
(jiffies > vmp->vm_posttime + coda_timeout * HZ) )
remove_wait_queue(&vmp->vm_sleep, &wait);
current->state = TASK_RUNNING;