From owner-freebsd-hackers Tue Jun 11 9:11:16 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from popcs.cs.tin.it (popcs.cs.tin.it [194.243.155.125]) by hub.freebsd.org (Postfix) with SMTP id 4C15537B41C for ; Tue, 11 Jun 2002 09:10:37 -0700 (PDT) Received: (qmail 7645 invoked from network); 11 Jun 2002 09:08:45 -0000 Received: from cruiser.cs.tin.it (HELO cs.tin.it) (212.216.178.193) by popcs.cs.tin.it with SMTP; 11 Jun 2002 09:08:45 -0000 Message-ID: <3D05BCE2.600E180A@cs.tin.it> Date: Tue, 11 Jun 2002 11:03:31 +0200 From: Ferruccio Vitale X-Mailer: Mozilla 4.79 [en] (X11; U; Linux 2.4.2 i386) X-Accept-Language: en MIME-Version: 1.0 To: hiten@uk.FreeBSD.org Cc: Andy Sporner , freebsd-hackers@FreeBSD.ORG Subject: Re: kernel thread References: <20020610174547.19800.qmail@web21106.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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