Mladen Nikitovic wrote:
> Hi,
>
> I'm wondering about how timeout actually works in practice. I have an
> implementation of a kernel-module and it registers one of it's functions via
> timeout.
>
> The question is whether each invocation of that callout function generates a
> new thread or if is simply a function call?
>
> I have a strange behavior that I currently cannot explain. It seems like the
> execution of the callout function takes quite some time, enough so that a new
> callout is invoked. So, if that happens, the question then is what happens
> with the previous instance, does it still exist? Could there be problems with
> global data that could be overwritten by the new instance? If there are
> indeed threads for each invocation of the callout function then I can
> understand that inconsistencies can occur if global data is not protected.
> Otherwise, I don't have a clue.
>
The previously scheduled timeout exists unless you call untimeout().
I don't believe that new threads are created, but there are
architecturally no guarantees that one invocation of a timeout function
run on the same thread as another. And on an SMP system, it is entirely
possible for two timeout functions to run at the same time.
If you have strict ordering requirements, or a function that is taking a
long time to run, you might find that timeout is not ideally suited --
timeout functions are supposed to adhere to the same restrictions as
interrupt handlers. Its possible that a taskq or a taskq (see
ddi_taskq_create(9F) used in conjuction with a timeout handler may be a
better solution for your needs.
-- Garrett
> Regards,
> Mladen
>
>
> This message posted from opensolaris.org
> _______________________________________________
> opensolaris-code mailing list
> [email protected]
> http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
>
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code