Homework 1, Problem 10 Output


[3:30pm] cse451> smartgdb ../userprog/nachos 
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16.1 (SmartGDB 0.9) (i686-unknown-linux), 
Copyright 1996 Free Software Foundation, Inc...
(gdb) conf args -x fork-yield
(gdb) source ~/prob9-routines.tcl
(gdb) r
Starting program: /d2/rprojects/nachos/nachos-3.4/code/test/../userprog/nachos -x fork-yield

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
No current thread
level = IntOff
now = IntOff
(gdb) c
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
No current thread
level = IntOff
now = IntOff
(gdb) c 
Continuing.

Breakpoint 6, Thread::Thread (this=0x8077710, threadName=0x80743f9 "main")
    at ../threads/thread.cc:103
103	{
No current thread
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOn)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 0
level = IntOff
now = IntOn
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 0
level = IntOn
now = IntOff
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOn)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 0
level = IntOff
now = IntOn
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, 
    which=PageFaultException, badVAddr=704) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 0
which = PageFaultException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=PageFaultException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 0
which = PageFaultException
type = 0
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, 
    which=PageFaultException, badVAddr=484) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 0
which = PageFaultException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=PageFaultException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 0
which = PageFaultException
type = 0
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, which=SyscallException, 
    badVAddr=0) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 0
which = SyscallException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=SyscallException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 0
which = SyscallException
type = 9
(gdb) c 
Continuing.

Breakpoint 3, do_system_call (syscall_num=9) at ../userprog/systemcall.cc:30
30	  switch (syscall_num) {
currentThread->ThreadID = 0
syscall_num = 9
reg4 = 0
reg5 = 0
reg6 = 0
reg7 = 0
(gdb) c 
Continuing.

Breakpoint 4, System_Fork () at ../userprog/systemcall.cc:422
422	  char * filename = new char[MAXFILENAMELENGTH];
currentThread->ThreadID = 0
(gdb) c 
Continuing.

Breakpoint 6, Thread::Thread (this=0x807f3d8, threadName=0x807f380 "main")
    at ../threads/thread.cc:103
103	{
currentThread->ThreadID = 0
(gdb) c 
Continuing.

Breakpoint 10, AddrSpace::CopyFrom (this=0x807f5e0, voidOurThread=0x807f3d8)
    at ../userprog/addrspace.cc:342
342	  OpenFile *swapfile = swap->file ();
currentThread->ThreadID = 0
((Thread*)voidOurThread)->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 7, Thread::Fork (this=0x807f3d8, 
    func=0x804fef8 , arg=40) at ../threads/thread.cc:203
203		  name, (size_t) func, arg);
func = (void (*)()) 0x804fef8 
arg = 40
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 0
level = IntOn
now = IntOff
(gdb) c 
Continuing.

Breakpoint 12, Scheduler::ReadyToRun (this=0x80776a8, thread=0x807f3d8)
    at ../threads/scheduler.cc:61
61	    DEBUG('t', "Putting thread %s on ready list.\n", thread->getName());
currentThread->ThreadID = 0
thread->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOn)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 0
level = IntOff
now = IntOn
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, 
    which=PageFaultException, badVAddr=520) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 0
which = PageFaultException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=PageFaultException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 0
which = PageFaultException
type = 2
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, 
    which=PageFaultException, badVAddr=768) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 0
which = PageFaultException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=PageFaultException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 0
which = PageFaultException
type = 2
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, which=SyscallException, 
    badVAddr=0) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 0
which = SyscallException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=SyscallException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 0
which = SyscallException
type = 10
(gdb) c 
Continuing.

Breakpoint 3, do_system_call (syscall_num=10) at ../userprog/systemcall.cc:30
30	  switch (syscall_num) {
currentThread->ThreadID = 0
syscall_num = 10
reg4 = 0
reg5 = 0
reg6 = 0
reg7 = 0
(gdb) c 
Continuing.

Breakpoint 5, System_Yield () at ../userprog/systemcall.cc:474
474	  currentThread->Yield();
currentThread->ThreadID = 0
(gdb) c 
Continuing.

Breakpoint 8, Thread::Yield (this=0x8077710) at ../threads/thread.cc:295
295	    IntStatus oldLevel = interrupt->SetLevel(IntOff);
currentThread->ThreadID = 0
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 0
level = IntOn
now = IntOff
(gdb) c 
Continuing.

Breakpoint 13, Scheduler::FindNextToRun (this=0x80776a8)
    at ../threads/scheduler.cc:85
85	      (Thread *) allThreads->Tail ()) {
currentThread->ThreadID = 0
((Thread*)(scheduler->readyList->first->item))->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 12, Scheduler::ReadyToRun (this=0x80776a8, thread=0x8077710)
    at ../threads/scheduler.cc:61
61	    DEBUG('t', "Putting thread %s on ready list.\n", thread->getName());
currentThread->ThreadID = 0
thread->ThreadID = 0
(gdb) c 
Continuing.

Breakpoint 14, Scheduler::Run (this=0x80776a8, nextThread=0x807f3d8)
    at ../threads/scheduler.cc:115
115	    Thread *oldThread = currentThread;
currentThread->ThreadID = 0
nextThread->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOn)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOff
now = IntOn
(gdb) c 
Continuing.

Breakpoint 9, Do_Fork (dummy=40) at ../userprog/systemcall.cc:527
527	  dummy = 0;                                          // Keep gcc happy
currentThread->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, 
    which=PageFaultException, badVAddr=520) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 1
which = PageFaultException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=PageFaultException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 1
which = PageFaultException
type = 0
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, 
    which=PageFaultException, badVAddr=768) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 1
which = PageFaultException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=PageFaultException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 1
which = PageFaultException
type = 0
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, which=SyscallException, 
    badVAddr=0) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 1
which = SyscallException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=SyscallException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 1
which = SyscallException
type = 10
(gdb) c 
Continuing.

Breakpoint 3, do_system_call (syscall_num=10) at ../userprog/systemcall.cc:30
30	  switch (syscall_num) {
currentThread->ThreadID = 1
syscall_num = 10
reg4 = 0
reg5 = 0
reg6 = 0
reg7 = 0
(gdb) c 
Continuing.

Breakpoint 5, System_Yield () at ../userprog/systemcall.cc:474
474	  currentThread->Yield();
currentThread->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 8, Thread::Yield (this=0x807f3d8) at ../threads/thread.cc:295
295	    IntStatus oldLevel = interrupt->SetLevel(IntOff);
currentThread->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOn
now = IntOff
(gdb) c 
Continuing.

Breakpoint 13, Scheduler::FindNextToRun (this=0x80776a8)
    at ../threads/scheduler.cc:85
85	      (Thread *) allThreads->Tail ()) {
currentThread->ThreadID = 1
((Thread*)(scheduler->readyList->first->item))->ThreadID = 0
(gdb) c 
Continuing.

Breakpoint 12, Scheduler::ReadyToRun (this=0x80776a8, thread=0x807f3d8)
    at ../threads/scheduler.cc:61
61	    DEBUG('t', "Putting thread %s on ready list.\n", thread->getName());
currentThread->ThreadID = 1
thread->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 14, Scheduler::Run (this=0x80776a8, nextThread=0x8077710)
    at ../threads/scheduler.cc:115
115	    Thread *oldThread = currentThread;
currentThread->ThreadID = 1
nextThread->ThreadID = 0
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOn)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 0
level = IntOff
now = IntOn
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, which=SyscallException, 
    badVAddr=0) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 0
which = SyscallException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=SyscallException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 0
which = SyscallException
type = 1
(gdb) c 
Continuing.

Breakpoint 3, do_system_call (syscall_num=1) at ../userprog/systemcall.cc:30
30	  switch (syscall_num) {
currentThread->ThreadID = 0
syscall_num = 1
reg4 = 0
reg5 = 0
reg6 = 0
reg7 = 0
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 0
level = IntOn
now = IntOff
(gdb) c 
Continuing.

Breakpoint 13, Scheduler::FindNextToRun (this=0x80776a8)
    at ../threads/scheduler.cc:85
85	      (Thread *) allThreads->Tail ()) {
currentThread->ThreadID = 0
((Thread*)(scheduler->readyList->first->item))->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 14, Scheduler::Run (this=0x80776a8, nextThread=0x807f3d8)
    at ../threads/scheduler.cc:115
115	    Thread *oldThread = currentThread;
currentThread->ThreadID = 0
nextThread->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOn)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOff
now = IntOn
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOff
now = IntOff
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOff
now = IntOff
(gdb) c 
Continuing.

Breakpoint 15, TimerInterruptHandler (dummy=0) at ../threads/system.cc:95
95	  dummy = 0; // Keep gcc happy
currentThread->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 16, Interrupt::YieldOnReturn (this=0x8077680)
    at ../machine/interrupt.cc:195
195	    ASSERT(inHandler == TRUE);  
currentThread->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 8, Thread::Yield (this=0x807f3d8) at ../threads/thread.cc:295
295	    IntStatus oldLevel = interrupt->SetLevel(IntOff);
currentThread->ThreadID = 1
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOn
now = IntOff
(gdb) c 
Continuing.

Breakpoint 13, Scheduler::FindNextToRun (this=0x80776a8)
    at ../threads/scheduler.cc:85
85	      (Thread *) allThreads->Tail ()) {
currentThread->ThreadID = 1
ReadyList is Empty
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOn)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOff
now = IntOn
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOff
now = IntOff
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOff
now = IntOff
(gdb) c 
Continuing.

Breakpoint 1, Machine::RaiseException (this=0x8077918, which=SyscallException, 
    badVAddr=0) at ../machine/machine.cc:103
103	    DEBUG('m', "Exception: %s\n", exceptionNames[which]);
currentThread->ThreadID = 1
which = SyscallException
(gdb) c 
Continuing.

Breakpoint 2, ExceptionHandler (which=SyscallException)
    at ../userprog/exception.cc:57
57	    if (which == SyscallException) {
currentThread->ThreadID = 1
which = SyscallException
type = 1
(gdb) c 
Continuing.

Breakpoint 3, do_system_call (syscall_num=1) at ../userprog/systemcall.cc:30
30	  switch (syscall_num) {
currentThread->ThreadID = 1
syscall_num = 1
reg4 = 0
reg5 = 0
reg6 = 0
reg7 = 0
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOn
now = IntOff
(gdb) c 
Continuing.

Breakpoint 12, Scheduler::ReadyToRun (this=0x80776a8, thread=0x8077710)
    at ../threads/scheduler.cc:61
61	    DEBUG('t', "Putting thread %s on ready list.\n", thread->getName());
currentThread->ThreadID = 1
thread->ThreadID = 0
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOn)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOff
now = IntOn
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 1
level = IntOn
now = IntOff
(gdb) c 
Continuing.

Breakpoint 13, Scheduler::FindNextToRun (this=0x80776a8)
    at ../threads/scheduler.cc:85
85	      (Thread *) allThreads->Tail ()) {
currentThread->ThreadID = 1
((Thread*)(scheduler->readyList->first->item))->ThreadID = 0
(gdb) c 
Continuing.

Breakpoint 14, Scheduler::Run (this=0x80776a8, nextThread=0x8077710)
    at ../threads/scheduler.cc:115
115	    Thread *oldThread = currentThread;
currentThread->ThreadID = 1
nextThread->ThreadID = 0
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOn)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 0
level = IntOff
now = IntOn
(gdb) c 
Continuing.

Breakpoint 11, Interrupt::SetLevel (this=0x8077680, now=IntOff)
    at ../machine/interrupt.cc:117
117	    IntStatus old = level;
currentThread->ThreadID = 0
level = IntOn
now = IntOff
(gdb) c 
Continuing.

Breakpoint 13, Scheduler::FindNextToRun (this=0x80776a8)
    at ../threads/scheduler.cc:85
85	      (Thread *) allThreads->Tail ()) {
currentThread->ThreadID = 0
ReadyList is Empty
(gdb) c 
Continuing.
Machine halting!

Ticks: total 147, idle 0, system 90, user 57
Context switches: 4
Disk I/O: reads 0, writes 0
Console I/O: reads 0, writes 0
Paging: faults 6, pageins 8, pageouts 0
Network I/O: packets received 0, sent 0

Cleaning up...

Program exited normally.
(gdb) quit


Steve Goddard
Last modified: Tue Oct 20 10:57:01 CDT 1998