Re: current->timeout = jiffies + ? -> schedule_timeout(?)

Mikael Pettersson (mikpe@csd.uu.se)
Thu, 5 Nov 1998 11:39:20 +0100 (MET)


In-Reply-To: <108510665@toto.iv>
X-Mailer: VM 6.61 under Emacs 19.34.1

Linus Torvalds writes:
> On Wed, 4 Nov 1998, Stephen Frost wrote:
> >
> > Is everything that does a 'current->timeout = jiffies + x;' obsolete and
> > needing to be redone as 'schedule_timeout(x);'?
>
> Yes. However, I've done some of it already. Sending me patches is still a
> good idea, though.

Here's a patch for ftape which broke in pre-2.1.127-7.
It seems to fix ftape for me, at least it compiles and
basic operations (mt, tar cf, and tar xvf) seem to work.
Caveat: ftape seems to want to issue repeated timeouts until
certain events (usually an interrupt or expiration of a
maximum time slice) so the diffs required a wee bit of though.
I'm cc:ing this to the ftape maintainer (Claus-Justus Heine)
so he can look them over.

/Mikael

--- linux-2.1.127-pre7/drivers/char/ftape/lowlevel/fdc-io.c.~1~ Mon Jun 8 22:32:26 1998
+++ linux-2.1.127-pre7/drivers/char/ftape/lowlevel/fdc-io.c Thu Nov 5 02:41:35 1998
@@ -388,6 +388,7 @@
struct wait_queue wait = {current, NULL};
sigset_t old_sigmask;
static int resetting = 0;
+ long timeout;
TRACE_FUN(ft_t_fdc_dma);

#if LINUX_VERSION_CODE >= KERNEL_VER(2,0,16)
@@ -400,7 +401,7 @@
}
#endif
/* timeout time will be up to USPT microseconds too long ! */
- current->timeout = jiffies + (1000 * time + FT_USPT - 1) / FT_USPT;
+ timeout = (1000 * time + FT_USPT - 1) / FT_USPT;
current->state = TASK_INTERRUPTIBLE;

spin_lock_irq(&current->sigmask_lock);
@@ -411,7 +412,7 @@

add_wait_queue(&ftape_wait_intr, &wait);
while (!ft_interrupt_seen && current->state != TASK_RUNNING) {
- schedule(); /* sets TASK_RUNNING on timeout */
+ timeout = schedule_timeout(timeout); /* sets TASK_RUNNING on timeout */
}

spin_lock_irq(&current->sigmask_lock);
@@ -433,7 +434,6 @@
*/
current->state = TASK_RUNNING;
if (ft_interrupt_seen) { /* woken up by interrupt */
- current->timeout = 0; /* interrupt hasn't cleared this */
ft_interrupt_seen = 0;
TRACE_EXIT 0;
}
--- linux-2.1.127-pre7/drivers/char/ftape/lowlevel/ftape-io.c.~1~ Tue Dec 2 18:33:16 1997
+++ linux-2.1.127-pre7/drivers/char/ftape/lowlevel/ftape-io.c Thu Nov 5 02:16:53 1998
@@ -93,13 +93,12 @@
unsigned int ticks = (time + FT_USPT - 1) / FT_USPT;

TRACE(ft_t_any, "%d msec, %d ticks", time/1000, ticks);
- current->timeout = jiffies + ticks;
current->state = TASK_INTERRUPTIBLE;
save_flags(flags);
sti();
do {
while (current->state != TASK_RUNNING) {
- schedule();
+ ticks = schedule_timeout(ticks);
}
/* Mmm. Isn't current->blocked == 0xffffffff ?
*/
@@ -108,7 +107,7 @@
"awoken by non-blocked signal :-(");
break; /* exit on signal */
}
- } while (current->timeout > 0);
+ } while (ticks > 0);
restore_flags(flags);
}
TRACE_EXIT;
--- linux-2.1.127-pre7/drivers/char/ftape/zftape/zftape-buffers.c.~1~ Tue Nov 25 23:45:28 1997
+++ linux-2.1.127-pre7/drivers/char/ftape/zftape/zftape-buffers.c Thu Nov 5 02:19:55 1998
@@ -122,9 +122,8 @@
void *new;

while ((new = kmalloc(size, GFP_KERNEL)) == NULL) {
- current->timeout = HZ/10;
current->state = TASK_INTERRUPTIBLE;
- schedule();
+ schedule_timeout(HZ/10);
}
memset(new, 0, size);
used_memory += size;

-
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/