From: Ben Pfaff Date: Mon, 30 Aug 2004 22:56:34 +0000 (+0000) Subject: Move filesys_init into main_thread. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c848687b0825179f834e4b1b7a1a52579d902744;p=pintos-anon Move filesys_init into main_thread. --- diff --git a/src/threads/init.c b/src/threads/init.c index 81188e9..6e06f2f 100644 --- a/src/threads/init.c +++ b/src/threads/init.c @@ -33,18 +33,12 @@ void power_off (void); static void main_thread (void *aux UNUSED) { - struct disk *hda; disk_init (); - hda = disk_get (1); - if (hda != NULL) - { - char buf[DISK_SECTOR_SIZE]; - disk_read (hda, 0, buf); - //hex_dump (buf, sizeof buf); - } - else - printk ("no hda\n"); - thread_execute ("a.out"); + +#ifdef FILESYS + filesys_init (true); +#endif + filesys_self_test (); } int @@ -81,10 +75,6 @@ main (void) timer_init (); kbd_init (); -#ifdef FILESYS - filesys_init (false); -#endif - thread_init (); t = thread_create ("main", main_thread, NULL); diff --git a/src/threads/malloc.c b/src/threads/malloc.c index 8da4c4e..72b4414 100644 --- a/src/threads/malloc.c +++ b/src/threads/malloc.c @@ -97,6 +97,23 @@ malloc (size_t size) return get_free_slot (d); } +void * +calloc (size_t a, size_t b) +{ + void *p; + size_t size; + + size = a * b; + if (size < a || size < b) + return NULL; + + p = malloc (size); + if (p != NULL) + memset (p, 0, size); + + return p; +} + void free (void *p) { diff --git a/src/threads/malloc.h b/src/threads/malloc.h index 2315312..a212592 100644 --- a/src/threads/malloc.h +++ b/src/threads/malloc.h @@ -5,8 +5,8 @@ #include void malloc_init (void); -void *malloc (size_t) - ATTRIBUTE ((malloc)); +void *malloc (size_t) ATTRIBUTE ((malloc)); +void *calloc (size_t, size_t) ATTRIBUTE ((malloc)); void free (void *); #endif /* malloc.h */