X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fthreads%2Finit.c;h=b099d02dd33ccbb8fb88889b821cde91ab772ad5;hb=828d300fd2039b686b69244c2bd6f8b87645086d;hp=ec71cec8432b4670a5473f0486760dea595489c1;hpb=6c5c6fdfe80bad40c90c19b67f00226610d59a38;p=pintos-anon diff --git a/src/threads/init.c b/src/threads/init.c index ec71cec..b099d02 100644 --- a/src/threads/init.c +++ b/src/threads/init.c @@ -41,10 +41,11 @@ static bool format_filesys; static char *initial_program; #endif -static thread_func main_thread; static void ram_init (void); static void argv_init (void); +int main (void) NO_RETURN; + int main (void) { @@ -60,6 +61,7 @@ main (void) argv_init (); /* Initialize memory system, segments, paging. */ + thread_init (); palloc_init (); paging_init (); #ifdef USERPROG @@ -79,30 +81,29 @@ main (void) 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 (); -} -/* Initial thread. */ -static void -main_thread (void *aux UNUSED) -{ #ifdef FILESYS + /* Initialize filesystem. */ disk_init (); filesys_init (format_filesys); fsutil_run (); #endif + printk ("Boot complete.\n"); + #ifdef USERPROG + /* Run a user program. */ if (initial_program != NULL) - thread_execute (initial_program); - else - PANIC ("no initial program specified"); -#else - PANIC ("boot successful"); + { + printk ("\nExecuting '%s':\n", initial_program); + thread_execute (initial_program); + } #endif + + /* Terminate this thread. */ + thread_exit (); } /* Clear BSS and obtain RAM size from loader. */