void
console_init (void)
{
- lock_init (&console_lock, "console");
+ lock_init (&console_lock);
}
/* Prints console statistics. */
}
}
+/* Returns true if the current thread has the console lock,
+ false otherwise. */
+static bool
+console_locked_by_current_thread (void)
+{
+ return intr_context () || lock_held_by_current_thread (&console_lock);
+}
+
/* The standard vprintf() function,
which is like printf() but uses a va_list.
Writes its output to both vga display and serial port. */
static void
putchar_unlocked (uint8_t c)
{
+ ASSERT (console_locked_by_current_thread ());
write_cnt++;
serial_putc (c);
vga_putc (c);