From: Ben Pfaff Date: Wed, 20 Jul 2005 04:44:55 +0000 (+0000) Subject: Eliminate race condition in console_print_stats() found by Sorav's X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=076c62799001f43a6f216755e71578d7143e1e05;p=pintos-anon Eliminate race condition in console_print_stats() found by Sorav's Checkbochs tool. --- diff --git a/src/lib/kernel/console.c b/src/lib/kernel/console.c index 53e08a0..176dd06 100644 --- a/src/lib/kernel/console.c +++ b/src/lib/kernel/console.c @@ -52,13 +52,6 @@ console_init (void) lock_init (&console_lock); } -/* Prints console statistics. */ -void -console_print_stats (void) -{ - printf ("Console: %lld characters output\n", write_cnt); -} - /* Acquires the console lock. */ static void acquire_console (void) @@ -93,6 +86,15 @@ console_locked_by_current_thread (void) return intr_context () || lock_held_by_current_thread (&console_lock); } +/* Prints console statistics. */ +void +console_print_stats (void) +{ + acquire_console (); + printf ("Console: %lld characters output\n", write_cnt); + release_console (); +} + /* The standard vprintf() function, which is like printf() but uses a va_list. Writes its output to both vga display and serial port. */