Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Jun 2002 11:03:31 +0200
From:      Ferruccio Vitale <freebsd@cs.tin.it>
To:        hiten@uk.FreeBSD.org
Cc:        Andy Sporner <sporner@nentec.de>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: kernel thread
Message-ID:  <3D05BCE2.600E180A@cs.tin.it>
References:  <20020610174547.19800.qmail@web21106.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hiten Pandya wrote:

> Ok, I cant find any man page called shutdown_kproc in either 4.3 or 4.4.
> Anyway, he wants to destroy a "thread", and not an "internal" daemon/process.
>
> To destroy a kernel thread, you need to make use of the kthread_exit()
> operation.  It is prototyped as follows:
>
> void kthread_exit(ecode);
>
> The *ecode* arg to kthread_exit() is used to specify the return code of
> the thread which you are going to terminate.
>
> Additonal Information can be found from:
> kthread(9)  -- (available in FreeBSD 5.0)
> sys/kthread.h
>
> HTH.
>
> Hiten
> hiten@uk.FreeBSD.org, hiten@xMach.org
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-hackers" in the body of the message

Ok, I found the way! :-)
On loading my kernel module, I call kthread_create to create the thread
(kproc_start is only a wrapper to it). Doing this, I also obtain the pid of new
process: this one enters in a loop as shown below:

while (var == 0) {
    kproc_suspend_loop(procp);
    .....
    tsleep(procp, PUSER, "procslp", hz);
}
kthread_exit(0);

On unloading this module, I set to 1 'var' and let the thread exits.

I hope this the right way to do it.
Thanx to everyone, guy :-)

Ferruccio

PS: oohh my english......


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D05BCE2.600E180A>