From a0470f561bcaa4de8ca4a85ceb5ebe58495bdeeb Mon Sep 17 00:00:00 2001
From: Ben Pfaff <blp@cs.stanford.edu>
Date: Sat, 11 Sep 2004 23:17:23 +0000
Subject: [PATCH] Turn off interrupts on output to lock out interrupt handlers
 that might want to write to the console.

---
 src/devices/vga.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

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 <string.h>
 #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. */
-- 
2.30.2