cgbahk / pintos

The pintos source distribution for JHU CS 318/418 projects
https://cs.jhu.edu/~huang/cs318/fall17/project/guide.html
0 stars 0 forks source link

pintos booting not successful #2

Closed cgbahk closed 5 years ago

cgbahk commented 5 years ago

This line does not work properly:

pintos/src/thread$ make qemu-nox

Output:

pintos/src/threads$ make qemu-nox
cd build && make qemu-nox
make[1]: Entering directory '/home/ub/repo/pintos/src/threads/build'
***
*** Use Ctrl-a x to exit qemu. If you are under GNU Screen or Tmux and 
*** its prefix key is Ctrl-a, press Ctrl-a twice and x to exit.
***
qemu-system-i386 -nographic -drive file=kernel.img,index=0,media=disk,format=raw -serial mon:stdio -gdb tcp::26000 -D qemu.log
Pintos hda1
Loading............
Kernel command line:
Pintos booting with Pintos hda1
Loading............
Kernel command line:
Pintos booting with Pintos hda1
Loading............
Kernel command line:
Pintos booting with Pintos hda1
Loading............
Kernel command line:
Pintos booting with Pintos hda1
Loading............
Kernel command line:
Pintos booting with Pintos hda1
Loading...QEMU: Terminated
make[1]: Leaving directory '/home/ub/repo/pintos/src/threads/build'

This should be sth like this https://github.com/james5233/PintOS

cgbahk commented 5 years ago

https://github.com/cgbahk/pintos/blob/68e1181b8807234c92464fce7b1f702a0d102621/src/threads/init.c#L94

and following lines seems problem. So it is related to memory

cgbahk commented 5 years ago

These seems important:


thread/
  start.S
  loader.S
  init.c
cgbahk commented 5 years ago

Failed on https://github.com/cgbahk/pintos/blob/68e1181b8807234c92464fce7b1f702a0d102621/src/lib/arithmetic.c#L111

seems like 'division by 0' occurs

(gdb) bt
#0  udiv64 (n=3968, d=0) at ../../lib/arithmetic.c:79
#1  0xc00280a1 in umod64 (d=0, n=3968) at ../../lib/arithmetic.c:134
#2  __umoddi3 (n=3968, d=0) at ../../lib/arithmetic.c:188
#3  0xc0026605 in format_integer (value=3968, is_signed=is_signed@entry=false, negative=false, 
    b=0xc0039550 <base_d>, c=0xc000ef20, output=0xc002a41d <vprintf_helper>, aux=0xc000ef6c)
    at ../../lib/stdio.c:510
#4  0xc002700c in __vprintf (format=<optimized out>, 
    args=0xc000efa8 "\200\226\003\300\217\004\002\300\304", <incomplete sequence \357>, 
    output=<optimized out>, aux=<optimized out>) at ../../lib/stdio.c:279
#5  0xc002a575 in vprintf (format=0xc002e36c "Pintos booting with %'u kB RAM...\n", 
    args=0xc000efa4 "\200\017") at ../../lib/kernel/console.c:131
#6  0xc00268e8 in printf (format=0xc002e36c "Pintos booting with %'u kB RAM...\n")
    at ../../lib/stdio.c:85
#7  0xc00204c0 in pintos_init () at ../../threads/init.c:94
#8  0xc002015d in start () at ../../threads/start.S:180
cgbahk commented 5 years ago

So printing format of integer(like) seems erroneous. After this patch, I can see a Boot complete

diff --git a/src/devices/timer.c b/src/devices/timer.c
index befaaae..0d71724 100644
--- a/src/devices/timer.c
+++ b/src/devices/timer.c
@@ -62,8 +62,6 @@ timer_calibrate (void)
   for (test_bit = high_bit >> 1; test_bit != high_bit >> 10; test_bit >>= 1)
     if (!too_many_loops (high_bit | test_bit))
       loops_per_tick |= test_bit;
-
-  printf ("%'"PRIu64" loops/s.\n", (uint64_t) loops_per_tick * TIMER_FREQ);
 }

 /* Returns the number of timer ticks since the OS booted. */
diff --git a/src/threads/init.c b/src/threads/init.c
index 9e2d3ae..497290c 100644
--- a/src/threads/init.c
+++ b/src/threads/init.c
@@ -90,10 +90,6 @@ pintos_init (void)
   thread_init ();
   console_init ();  

-  /* Greet user. */
-  printf ("Pintos booting with %'"PRIu32" kB RAM...\n",
-          init_ram_pages * PGSIZE / 1024);
-
   /* Initialize memory system. */
   palloc_init (user_page_limit);
   malloc_init ();
diff --git a/src/threads/palloc.c b/src/threads/palloc.c
index 4fc8394..f86ed8b 100644
--- a/src/threads/palloc.c
+++ b/src/threads/palloc.c
@@ -161,8 +161,6 @@ init_pool (struct pool *p, void *base, size_t page_cnt, const char *name)
     PANIC ("Not enough memory in %s for bitmap.", name);
   page_cnt -= bm_pages;

-  printf ("%zu pages available in %s.\n", page_cnt, name);
-
   /* Initialize the pool. */
   lock_init (&p->lock);
   p->used_map = bitmap_create_in_buf (page_cnt, base, bm_pages * PGSIZE);
cgbahk commented 5 years ago

So the booting is completed. Further issue will be on #4