2001-11-11 14:35:33

by Duncan Sands

[permalink] [raw]
Subject: tasklets and finalization

Hi! In the driver I'm working on, a tasklet is scheduled
from time to time. Are there any guarantees as to when
it will run? I'm worried, for example, about module
unloading: how to be sure that the scheduled tasklet runs
before the module is unloaded?

Thanks,

Duncan.

PS: My first thought was to use tasklet_kill, but according
to "Linux device drivers" (2nd ed) that may hang if the
tasklet isn't pending.

PPS: Another thought was to call schedule(), hoping that
all pending asklets will get run then, but is that reliable?


2001-11-12 08:22:15

by Duncan Sands

[permalink] [raw]
Subject: Re: tasklets and finalization

On Monday 12 November 2001 8:57 am, you wrote:
> On 11-Nov-2001 Duncan Sands wrote:
> > PS: My first thought was to use tasklet_kill, but according
> > to "Linux device drivers" (2nd ed) that may hang if the
> > tasklet isn't pending.
>
> true.
>
> > PPS: Another thought was to call schedule(), hoping that
> > all pending asklets will get run then, but is that reliable?
>
> if you are sure, the tasklet isn't rescheduled within the tasklet
> i THINK this will do it:
>
> current->policy |= SCHED_YIELD;
> schedule();
>
> me

Thanks for thinking about this. Here's a thought:

...
tasklet_schedule(&my_tasklet);
tasklet_kill(&my_tasklet);
...

Since (as far as I can see) there is no way the
tasklet will run before calling tasklet_kill, this
should just kill any pending tasklets.

Duncan.

2001-11-12 08:36:29

by Mathijs Mohlmann

[permalink] [raw]
Subject: Re: tasklets and finalization


On 12-Nov-2001 Duncan Sands wrote:
> ...
> tasklet_schedule(&my_tasklet);
> tasklet_kill(&my_tasklet);
> ...
>
> Since (as far as I can see) there is no way the
> tasklet will run before calling tasklet_kill, this
> should just kill any pending tasklets.

cpu#1 cpu#2
tasklet_schedule
tasklet_schedule
run tasklet
tasklet_kill
loop


--
me

2001-11-12 08:42:18

by Duncan Sands

[permalink] [raw]
Subject: Re: tasklets and finalization

On Monday 12 November 2001 9:35 am, Mathijs Mohlmann wrote:
> On 12-Nov-2001 Duncan Sands wrote:
> > ...
> > tasklet_schedule(&my_tasklet);
> > tasklet_kill(&my_tasklet);
> > ...
> >
> > Since (as far as I can see) there is no way the
> > tasklet will run before calling tasklet_kill, this
> > should just kill any pending tasklets.
>
> cpu#1 cpu#2
> tasklet_schedule
> tasklet_schedule
> run tasklet
> tasklet_kill
> loop

Aaargh! I should think before typing. It is too
early in the morning here...

Duncan.