make loop counter volatile to prevent gcc4.1 from optimizing away entire loop body
[pintos-anon] / src / devices / vga.c
index fcdc689e9a1dc6dd8e0dab5d11394a8596f58b78..949dd975eaec8da2ae0e34551b7ca23765a14792 100644 (file)
@@ -1,9 +1,11 @@
-#include "vga.h"
+#include "devices/vga.h"
+#include <round.h>
 #include <stdint.h>
 #include <stddef.h>
-#include "lib/lib.h"
+#include <string.h>
 #include "threads/io.h"
-#include "threads/mmu.h"
+#include "threads/interrupt.h"
+#include "threads/vaddr.h"
 
 /* VGA text screen support.  See [FREEVGA] for more information. */
 
@@ -37,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':
@@ -76,6 +82,8 @@ vga_putc (int c)
 
   /* Update cursor position. */
   move_cursor ();
+
+  intr_set_level (old_level);
 }
 \f
 /* Clears the screen and moves the cursor to the upper left. */