projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some suggestions from "Waqar Mohsin" <wmohsin@gmail.com>
[pintos-anon]
/
src
/
lib
/
kernel
/
console.c
diff --git
a/src/lib/kernel/console.c
b/src/lib/kernel/console.c
index d09801d984a6f2250b18f15d819dc781c521f741..865b13b2cd810b0805acead8ec9f4e3e038f609a 100644
(file)
--- a/
src/lib/kernel/console.c
+++ b/
src/lib/kernel/console.c
@@
-49,7
+49,7
@@
static int64_t write_cnt;
void
console_init (void)
{
void
console_init (void)
{
- lock_init (&console_lock
, "console"
);
+ lock_init (&console_lock);
}
/* Prints console statistics. */
}
/* Prints console statistics. */
@@
-85,6
+85,14
@@
release_console (void)
}
}
}
}
+/* 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. */
/* The standard vprintf() function,
which is like printf() but uses a va_list.
Writes its output to both vga display and serial port. */
@@
-150,6
+158,7
@@
vprintf_helper (char c, void *char_cnt_)
static void
putchar_unlocked (uint8_t c)
{
static void
putchar_unlocked (uint8_t c)
{
+ ASSERT (console_locked_by_current_thread ());
write_cnt++;
serial_putc (c);
vga_putc (c);
write_cnt++;
serial_putc (c);
vga_putc (c);