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

Steven Rostedt
2006-07-28T13:34:15Z

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