Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Jan 2004 15:08:22 +0100
From:      "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net>
To:        FreeBSD-hackers@FreeBSD.org
Subject:   kernel threads and printf locking question
Message-ID:  <200401101508.22640.Danovitsch@Vitsch.net>

next in thread | raw e-mail | index | archive | help

Hi,

I am writing a kernel module in which I have created a kernel thread with 
kthread_create. For debugging I have added a couple of printf's in the 
thread-routine. Running the module on a single-proc system works fine, but 
when running it on one of my SMP machines the console freezes after a couple 
of seconds.

I have been looking through the archives and through some other drivers ( for 
example randomdev.c uses a kthread and printf's from it ). I found a version 
of randomdev.c with google that lock's Giant while calling printf, but 
randomdev.c in my src-tree has no locking there. (I'm using 5.1-RELEASE)
Right now I have changed all printf's in my module into a macro-function that 
checks if ( curproc == our thread ) and locks Giant if true, then printf's. 
(since some of the routines get called both from the thread and from other 
places.)

What is the current state of printf-locking when called from a kernel thread? 
Is locking Giant the only possible way to avoid problems on SMP systems, or 
is there a more fine-grained printf lock available? (on 5.1-RELEASE or 
-current)

thanks,
Daan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200401101508.22640.Danovitsch>