From: Ben Pfaff Date: Sat, 11 Sep 2004 23:17:23 +0000 (+0000) Subject: Turn off interrupts on output to lock out interrupt handlers that X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0470f561bcaa4de8ca4a85ceb5ebe58495bdeeb;p=pintos-anon Turn off interrupts on output to lock out interrupt handlers that might want to write to the console. --- diff --git a/src/devices/vga.c b/src/devices/vga.c index bc2d6b7..8ab08f6 100644 --- a/src/devices/vga.c +++ b/src/devices/vga.c @@ -5,6 +5,7 @@ #include #include "threads/io.h" #include "threads/mmu.h" +#include "threads/interrupt.h" /* VGA text screen support. See [FREEVGA] for more information. */ @@ -38,10 +39,14 @@ vga_init (void) } /* Writes C to the VGA text display, interpreting control - characters in the conventional ways. */ + characters in the conventional ways. */ void vga_putc (int c) { + /* Disable interrupts to lock out interrupt handlers + that might write to the console. */ + enum intr_level old_level = intr_disable (); + switch (c) { case '\n': @@ -77,6 +82,8 @@ vga_putc (int c) /* Update cursor position. */ move_cursor (); + + intr_set_level (old_level); } /* Clears the screen and moves the cursor to the upper left. */