Subject: Re: Kernel threads
To: None <sommerfeld@orchard.arlington.ma.us>
From: Bharani Chadalavada <bharani.chadalavada@nexsi.com>
List: tech-kern
Date: 02/02/2001 22:45:01
Bill Sommerfeld wrote:

> > I am a newbie to NetBSD kernel hacking and I am trying to implement a
> > device monitor routine which needs to run with interrupts
> > enabled(reading some registers etc). I am thinking of doing this using
> > kernel threads.(like a pagedaemon, reaper etc). Now this runs only in
> > the kernel context. Can I do something similar to the way reaper is
> > implemented for example?
>
> Yes.

That is what I thought...Thank you!!

>
>
> > It would be great if someone gives me some links which describe how
> > to do this or some code snippets in other ports etc.. (my machine is
> > mips based),
>
> A number of device drivers now spawn kernel threads; you might want to
> take a look for calls to kthread_create() and kthread_create1() in
> drivers all over the system, including the USB and PCMCIA subsystems.
>
> for instance,
>
>         sys/dev/ic/i82365.c
>         sys/dev/ic/tcic2.c
>

That is helpful. Thank you again!!

>
> The interface is currently a little convoluted, as one cannot create
> threads extremely early in boot; instead, kthread_create() is given a
> pointer to a function which is then called back when it's safe to
> actually create the thread; that callback function should call
> kthread_create1() with the "base" function of the thread.
>
>                                         - Bill

When you say, extremely early boot, it is device configuration?? And I
assume that the kthread_run_deferred_queue() is the one which calls all
these call-back functions. Am I right?

Thank you,
Bharani.