printk does all this, usually. It is synchronous, so when
it returns to your code, the text is on the screen.
The only exception to this is when you perform a printk
from within an interrupt handler *while* printk itself
is executing in non-interrupt context. When this rare
situation occurs, the text is buffered, to be emitted
by the non-interrupt code before it returns to its caller.
If the printk-within-printk buffering is a problem for you,
(which I doubt) then you could disable interrupts while
running printk. Something like this:
--- linux-2.4.18-pre6/kernel/printk.c Tue Jan 22 12:38:31 2002
+++ linux-akpm/kernel/printk.c Tue Jan 22 15:40:57 2002
@@ -412,6 +412,10 @@ asmlinkage int printk(const char *fmt, .
char *p;
static char printk_buf[1024];
static int log_level_unknown = 1;
+ static spinlock_t printk_lock = SPIN_LOCK_UNLOCKED;
+ unsigned long xflags;
+
+ spin_lock_irqsave(&printk_lock, xflags);
if (oops_in_progress) {
/* If a crash is occurring, make sure we can't deadlock */
@@ -471,6 +475,7 @@ asmlinkage int printk(const char *fmt, .
spin_unlock_irqrestore(&logbuf_lock, flags);
}
out:
+ spin_unlock_irqrestore(&printk_lock, xflags);
return printed_len;
}
EXPORT_SYMBOL(printk);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/