static int jiq_read_run_timer(char *buf, char **start, off_t offset, int len, int *eof, void *data) { jiq_data.len = 0; /* prepare the argument for jiq_print() */ jiq_data.buf = buf; jiq_data.jiffies = jiffies; init_timer(&jiq_timer); /* init the timer structure */ jiq_timer.function = jiq_timedout; jiq_timer.data = (unsigned long)&jiq_data; jiq_timer.expires = jiffies + HZ; /* one second */ jiq_print(&jiq_data); /* print and go to sleep */ add_timer(&jiq_timer); interruptible_sleep_on(&jiq_wait); /* RACE */ del_timer_sync(&jiq_timer); /* in case a signal woke us up */ *eof = 1; return jiq_data.len; }
static void jiq_timedout(unsigned long ptr) { jiq_print((void *)ptr); /* print a line */ wake_up_interruptible(&jiq_wait); /* awake the process */ }
/* * Call jiq_print from a tasklet */ static void jiq_print_tasklet(unsigned long ptr) { if (jiq_print ((void *) ptr)) tasklet_schedule (&jiq_tasklet); }
/* * Call jiq_print from a tasklet */ static void jiq_print_tasklet(unsigned long ptr) { if (!jiq_print((struct clientdata *)ptr)) return; tasklet_schedule(&jiq_tasklet); }