Don't assume 4 kB pages.
[pintos-anon] / src / threads / init.c
index 35ce92a2e255c7b68865931877dba832c9ff048a..9ab04476741e4f4580afc15ed454e71e34a237e6 100644 (file)
@@ -1,4 +1,5 @@
 #include "threads/init.h"
+#include <console.h>
 #include <debug.h>
 #include <limits.h>
 #include <random.h>
@@ -18,6 +19,7 @@
 #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"
@@ -52,19 +54,20 @@ int main (void) NO_RETURN;
 int
 main (void)
 {
-  /* Needed by printf(), so initialize them very early. */
+  /* Initialize everything needed for printf() first. */
   ram_init ();
+  thread_init ();
   vga_init ();
   serial_init_poll ();
+  console_init ();
 
   /* Greet user. */
-  printf ("Booting cnachos86 with %'d kB RAM...\n", ram_pages * 4);
+  printf ("Pintos booting with %'d kB RAM...\n", ram_pages * (PGSIZE / 1024));
 
   /* Parse command line. */
   argv_init ();
 
   /* Initialize memory system, segments, paging. */
-  thread_init ();
   palloc_init ();
   paging_init ();
 #ifdef USERPROG
@@ -73,7 +76,7 @@ main (void)
 #endif
   malloc_init ();
 
-  /* Set random seed if not already done. */
+  /* Set random seed if argv_init() didn't. */
   random_init (0);
 
   /* Initialize interrupt handlers. */
@@ -105,6 +108,8 @@ main (void)
       printf ("\nExecuting '%s':\n", initial_program);
       thread_execute (initial_program); 
     }
+#else
+  test ();
 #endif
 
   /* Terminate this thread. */