Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision 97d42d5e11dcee14940db22d71b410bb48103e65)
+++ kernel/generic/src/console/console.c	(revision 9ea8fdb468d87b5fe943968fa3901cbdae78af90)
@@ -60,5 +60,5 @@
 
 /** Kernel log initialized */
-static bool klog_inited = false;
+static atomic_t klog_inited = {false};
 
 /** First kernel log characters */
@@ -75,5 +75,5 @@
 
 /** Kernel log spinlock */
-SPINLOCK_STATIC_INITIALIZE_NAME(klog_lock, "*klog_lock");
+SPINLOCK_STATIC_INITIALIZE_NAME(klog_lock, "klog_lock");
 
 /** Physical memory area used for klog buffer */
@@ -166,8 +166,5 @@
 	
 	event_set_unmask_callback(EVENT_KLOG, klog_update);
-	
-	spinlock_lock(&klog_lock);
-	klog_inited = true;
-	spinlock_unlock(&klog_lock);
+	atomic_set(&klog_inited, true);
 }
 
@@ -264,7 +261,10 @@
 void klog_update(void)
 {
+	if (!atomic_get(&klog_inited))
+		return;
+	
 	spinlock_lock(&klog_lock);
 	
-	if ((klog_inited) && (klog_uspace > 0)) {
+	if (klog_uspace > 0) {
 		if (event_notify_3(EVENT_KLOG, true, klog_start, klog_len,
 		    klog_uspace) == EOK)
@@ -277,12 +277,23 @@
 void putchar(const wchar_t ch)
 {
+	bool ordy = ((stdout) && (stdout->op->write));
+	
 	spinlock_lock(&klog_lock);
 	
-	if ((klog_stored > 0) && (stdout) && (stdout->op->write)) {
-		/* Print charaters stored in kernel log */
-		size_t i;
-		for (i = klog_len - klog_stored; i < klog_len; i++)
-			stdout->op->write(stdout, klog[(klog_start + i) % KLOG_LENGTH], silent);
-		klog_stored = 0;
+	/* Print charaters stored in kernel log */
+	if (ordy) {
+		while (klog_stored > 0) {
+			wchar_t tmp = klog[(klog_start + klog_len - klog_stored) % KLOG_LENGTH];
+			klog_stored--;
+			
+			/*
+			 * We need to give up the spinlock for
+			 * the physical operation of writting out
+			 * the character.
+			 */
+			spinlock_unlock(&klog_lock);
+			stdout->op->write(stdout, tmp, silent);
+			spinlock_lock(&klog_lock);
+		}
 	}
 	
@@ -294,7 +305,22 @@
 		klog_start = (klog_start + 1) % KLOG_LENGTH;
 	
-	if ((stdout) && (stdout->op->write))
+	if (!ordy) {
+		if (klog_stored < klog_len)
+			klog_stored++;
+	}
+	
+	/* The character is stored for uspace */
+	if (klog_uspace < klog_len)
+		klog_uspace++;
+	
+	spinlock_unlock(&klog_lock);
+	
+	if (ordy) {
+		/*
+		 * Output the character. In this case
+		 * it should be no longer buffered.
+		 */
 		stdout->op->write(stdout, ch, silent);
-	else {
+	} else {
 		/*
 		 * No standard output routine defined yet.
@@ -306,17 +332,7 @@
 		 * Note that the early_putc() function might be
 		 * a no-op on certain hardware configurations.
-		 *
 		 */
 		early_putchar(ch);
-		
-		if (klog_stored < klog_len)
-			klog_stored++;
-	}
-	
-	/* The character is stored for uspace */
-	if (klog_uspace < klog_len)
-		klog_uspace++;
-	
-	spinlock_unlock(&klog_lock);
+	}
 	
 	/* Force notification on newline */
