Re: A better interface, perhaps: a timed signal flag

From: Steven Rostedt
Date: Fri Jul 28 2006 - 09:32:04 EST


On Wed, 2006-07-26 at 10:45 -0400, Theodore Tso wrote:

> If we had such an interface, then the application would look like
> this:
>
> volatile int flag = 0;
>
> register_timout(&time_val, &flag);
> while (work to do) {
> do_a_bit_of_work();
> if (flag)
> break;
> }

This wouldn't work simply because the timeout would most likely be
implemented with an interrupt, and the address of flag is in userspace,
so the interrupt handler couldn't modify it (without doing some sort of
single handling, and thus slow down what you want).

What you could have is this:

volatile int *flag;

register_timeout(&time_val, &flag);
while (work_to_do()) {
do_a_bit_of_work();
if (*flag)
break;
}

Where the kernel would register a location to set a timeout with, and
the kernel would setup a flag for you and then map it into userspace.
Perhaps only allow one flag per task and place it as a field of the task
structure. There's no reason that the tasks own task sturct cant be
mapped read only to user space, is there?

-- Steve


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