projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add comments.
[pintos-anon]
/
src
/
threads
/
init.c
diff --git
a/src/threads/init.c
b/src/threads/init.c
index ae864981341d110464c59985d3ccd94e8acf193a..b099d02dd33ccbb8fb88889b821cde91ab772ad5 100644
(file)
--- a/
src/threads/init.c
+++ b/
src/threads/init.c
@@
-3,7
+3,6
@@
#include <stddef.h>
#include <limits.h>
#include "debug.h"
#include <stddef.h>
#include <limits.h>
#include "debug.h"
-#include "gdt.h"
#include "interrupt.h"
#include "io.h"
#include "kbd.h"
#include "interrupt.h"
#include "io.h"
#include "kbd.h"
@@
-17,8
+16,12
@@
#include "serial.h"
#include "thread.h"
#include "timer.h"
#include "serial.h"
#include "thread.h"
#include "timer.h"
-#include "tss.h"
#include "vga.h"
#include "vga.h"
+#ifdef USERPROG
+#include "exception.h"
+#include "gdt.h"
+#include "tss.h"
+#endif
#ifdef FILESYS
#include "filesys.h"
#include "disk.h"
#ifdef FILESYS
#include "filesys.h"
#include "disk.h"
@@
-38,10
+41,11
@@
static bool format_filesys;
static char *initial_program;
#endif
static char *initial_program;
#endif
-static thread_func main_thread;
static void ram_init (void);
static void argv_init (void);
static void ram_init (void);
static void argv_init (void);
+int main (void) NO_RETURN;
+
int
main (void)
{
int
main (void)
{
@@
-57,10
+61,13
@@
main (void)
argv_init ();
/* Initialize memory system, segments, paging. */
argv_init ();
/* Initialize memory system, segments, paging. */
+ thread_init ();
palloc_init ();
paging_init ();
palloc_init ();
paging_init ();
+#ifdef USERPROG
tss_init ();
gdt_init ();
tss_init ();
gdt_init ();
+#endif
malloc_init ();
/* Set random seed if not already done. */
malloc_init ();
/* Set random seed if not already done. */
@@
-70,29
+77,33
@@
main (void)
intr_init ();
timer_init ();
kbd_init ();
intr_init ();
timer_init ();
kbd_init ();
+#ifdef USERPROG
+ exception_init ();
+#endif
- /* Do everything else in a system thread. */
- thread_init ();
- thread_create ("main", main_thread, NULL);
+ /* Start thread scheduler and enable interrupts. */
thread_start ();
thread_start ();
-}
-/* Initial thread. */
-static void
-main_thread (void *aux UNUSED)
-{
#ifdef FILESYS
#ifdef FILESYS
+ /* Initialize filesystem. */
disk_init ();
filesys_init (format_filesys);
fsutil_run ();
#endif
disk_init ();
filesys_init (format_filesys);
fsutil_run ();
#endif
+ printk ("Boot complete.\n");
+
#ifdef USERPROG
#ifdef USERPROG
+ /* Run a user program. */
if (initial_program != NULL)
if (initial_program != NULL)
- thread_execute (initial_program);
- else
- PANIC ("no initial program specified");
+ {
+ printk ("\nExecuting '%s':\n", initial_program);
+ thread_execute (initial_program);
+ }
#endif
#endif
+
+ /* Terminate this thread. */
+ thread_exit ();
}
\f
/* Clear BSS and obtain RAM size from loader. */
}
\f
/* Clear BSS and obtain RAM size from loader. */
@@
-174,8
+185,9
@@
argv_init (void)
" -p FILENAME Print the contents of FILENAME\n"
" -r FILENAME Delete FILENAME\n"
" -ls List the files in the filesystem\n"
" -p FILENAME Print the contents of FILENAME\n"
" -r FILENAME Delete FILENAME\n"
" -ls List the files in the filesystem\n"
- " -D Dump complete filesystem contents\n"
);
+ " -D Dump complete filesystem contents\n"
#endif
#endif
+ );
}
else
PANIC ("unknown option `%s'", argv[i]);
}
else
PANIC ("unknown option `%s'", argv[i]);