Add a little demo/test code for the `threads' project.
[pintos-anon] / src / threads / init.c
index 57d5301c3ae3a0477e3aeb846c0ec97b01d940b3..589a23efc5b0ec779068052dcbbaaa136f036200 100644 (file)
@@ -1,22 +1,25 @@
-#include "init.h"
-#include <stdint.h>
-#include <stddef.h>
+#include "threads/init.h"
+#include <debug.h>
 #include <limits.h>
-#include "interrupt.h"
-#include "io.h"
-#include "loader.h"
-#include "malloc.h"
-#include "mmu.h"
-#include "paging.h"
-#include "palloc.h"
-#include "thread.h"
+#include <random.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include "devices/kbd.h"
 #include "devices/serial.h"
 #include "devices/timer.h"
 #include "devices/vga.h"
-#include "lib/debug.h"
-#include "lib/lib.h"
-#include "lib/random.h"
+#include "threads/interrupt.h"
+#include "threads/io.h"
+#include "threads/loader.h"
+#include "threads/malloc.h"
+#include "threads/mmu.h"
+#include "threads/paging.h"
+#include "threads/palloc.h"
+#include "threads/test.h"
+#include "threads/thread.h"
 #ifdef USERPROG
 #include "userprog/exception.h"
 #include "userprog/gdt.h"
@@ -50,13 +53,13 @@ int main (void) NO_RETURN;
 int
 main (void)
 {
-  /* Needed by printk(), so initialize them very early. */
+  /* Needed by printf(), so initialize them very early. */
   ram_init ();
   vga_init ();
-  serial_init ();
+  serial_init_poll ();
 
   /* Greet user. */
-  printk ("Booting cnachos86 with %'d kB RAM...\n", ram_pages * 4);
+  printf ("Pintos booting with %'d kB RAM...\n", ram_pages * 4);
 
   /* Parse command line. */
   argv_init ();
@@ -85,6 +88,7 @@ main (void)
 
   /* Start thread scheduler and enable interrupts. */
   thread_start ();
+  serial_init_queue ();
 
 #ifdef FILESYS
   /* Initialize filesystem. */
@@ -93,15 +97,17 @@ main (void)
   fsutil_run ();
 #endif
 
-  printk ("Boot complete.\n");
-
+  printf ("Boot complete.\n");
+  
 #ifdef USERPROG
   /* Run a user program. */
   if (initial_program != NULL)
     {
-      printk ("\nExecuting '%s':\n", initial_program);
+      printf ("\nExecuting '%s':\n", initial_program);
       thread_execute (initial_program); 
     }
+#else
+  test ();
 #endif
 
   /* Terminate this thread. */
@@ -173,7 +179,7 @@ argv_init (void)
 #endif
     else if (!strcmp (argv[i], "-u"))
       {
-        printk (
+        printf (
           "Kernel options:\n"
           " -rs SEED            Seed random seed to SEED.\n"
           " -d CLASS[,...]      Enable the given classes of debug messages.\n"