From owner-freebsd-smp Thu Oct 5 8:55:17 2000 Delivered-To: freebsd-smp@freebsd.org Received: from io.yi.org (24.67.218.234.bc.wave.home.com [24.67.218.234]) by hub.freebsd.org (Postfix) with ESMTP id 194A037B503 for ; Thu, 5 Oct 2000 08:55:09 -0700 (PDT) Received: from io.yi.org (localhost.gvcl1.bc.wave.home.com [127.0.0.1]) by io.yi.org (Postfix) with ESMTP id 24CD9BA76; Thu, 5 Oct 2000 08:55:09 -0700 (PDT) X-Mailer: exmh version 2.1.1 10/15/1999 To: Mark Murray Cc: Boris Popov , freebsd-smp@FreeBSD.ORG Subject: Re: Problems with kthread_exit() and SMPng In-Reply-To: Message from Mark Murray of "Thu, 05 Oct 2000 13:47:34 +0200." <200010051147.e95BlZL04193@grimreaper.grondar.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 05 Oct 2000 08:55:09 -0700 From: Jake Burkholder Message-Id: <20001005155509.24CD9BA76@io.yi.org> Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > > Currently I'm trying to make KLD which uses kernel threads > > unloadable under recent -current. > > I have exactly the same problem with the devrandom driver. I'll > test your patch with my driver. > > Thanks! > I'll bet that you just need to hold Giant before calling kthread_exit(), since exit1() isn't MP-safe yet. Running kernel threads outside of the lock is pretty iffy right now. void my_thread(void*arg) { while(wearewanted) { do_something(); tsleep(); } exited = 1; mtx_enter(&Giant, MTX_DEF); kthread_exit(0); } This should work, but depending on what you're doing it might be better to grab Giant as the first thing the thread does. Jake To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message