Date: Thu, 05 Oct 2000 11:53:53 -0700 (PDT) From: John Baldwin <jhb@FreeBSD.org> To: Mark Murray <mark@grondar.za> Cc: freebsd-smp@FreeBSD.org, Boris Popov <bp@butya.kz>, Jake Burkholder <jburkhol@home.com> Subject: Re: Problems with kthread_exit() and SMPng Message-ID: <XFMail.001005115353.jhb@FreeBSD.org> In-Reply-To: <200010051826.e95IQfJ12260@grimreaper.grondar.za>
next in thread | previous in thread | raw e-mail | index | archive | help
On 05-Oct-00 Mark Murray wrote:
>> 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.
>
> Hmm. I'll try that. Will the (kthread_)exit release Giant?
Yes. cpu_exit() (called by exit1()) releases Giant as its
final act before calling cpu_switch() (should be cpu_throw())
to run the next process.
> My thread does a lot of work; if it holds Giant, then it can't be
> preempted. That would be a problem.
Errr, it can be pre-empted, but your thread doesn't need Giant except
for kthread_exit().
> There is another problem; printf's inside a kthread corrupt like
> crazy. They look very unthreadsafe.
printf() is not MP safe. :-P You probably want to grab Giant before
calling printf().
> M
> --
> Mark Murray
> Join the anti-SPAM movement: http://www.cauce.org
--
John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.001005115353.jhb>
