UCSD Main WebsiteUCSD Jacobs SchoolDepartment of Computer Science and Engineering
spacer gif
spacer gif
CSE 120
spacer gifspacer gif
spacer gif
spacer gifCourse Overview
spacer gifspacer gifStructure
spacer gifspacer gifGrading
spacer gifspacer gifCollaboration
spacer gifspacer gifUseful books
spacer gif
spacer gifspacer gifSchedule
spacer gif
spacer gifProjects
spacer gif
spacer gif Homeworks
spacer gif
spacer gifWebBoard
spacer gif
spacer gif
spacer gif
Search
spacer gifspacer gifspacer gif
Advanced search  arrows gif

spacer gif
spacer gifspacer gif
spacer gif
spacer gif
spacer gif

spacer gif

spacer gif
spacer gifspacer gifspacer gif
spacer gif

Nachos Project 0: Install

Due: Tuesday, October 4th, at Midnight.

Note: This is an individual assignment! Each student must submit a copy of their session's output.

In this "project" you will familiarize yourself with installing and compiling the Nachos distribution. You will also practice using the debugger on the nachos executable as it runs. The tutorial below should not take that much time at all; if you seem to be having serious problems, send us mail immediately.

  1. [0 pts] Unpack the nachos distribution using gunzip and tar:
    % gunzip -c -d ~/../public/cse120-nachos.tar.gz | tar xvf -

    Be sure that you have "prepped" your account for the class. If you were not prompted to prep "cs120f" when you logged in, do it from the command line:

    % prep cs120f

    Build a nachos executable using the gmake command in the code directory:

    % cd nachos-3.4/code
    % gmake

    This will create versions of the nachos executable in various subdirectories. We will be using the threads directory for the upcoming project 1, so let's use that nachos exectuable. Run it without any arguments -- it should produce output similar to the following:

    [cs120f@ieng9]$ cd threads
    [cs120f@ieng9]$ ./nachos
    *** thread 0 looped 0 times
    *** thread 1 looped 0 times
    *** thread 0 looped 1 times
    *** thread 1 looped 1 times
    *** thread 0 looped 2 times
    *** thread 1 looped 2 times
    *** thread 0 looped 3 times
    *** thread 1 looped 3 times
    *** thread 0 looped 4 times
    *** thread 1 looped 4 times
    No threads ready or runnable, and no pending interrupts.
    Assuming the program completed.
    Machine halting!
    
    Ticks: total 130, idle 0, system 130, user 0
    Disk I/O: reads 0, writes 0
    Console I/O: reads 0, writes 0
    Paging: faults 0
    Network I/O: packets received 0, sent 0
    
    Cleaning up...
  2. [5 pts] Nachos is like any other program in that it starts by running the main() procedure. In Nachos, main() is in threads/main.cc. If you examine threads/main.cc, you will see that you are executing the ThreadTest function (in threadtest.cc). It is the printf in the SimpleTest class that produced the initial output when you ran the nachos executable. ThreadTest is a simple example of a concurrent program. In this case there are two independent threads of control executing "at the same time" and accessing the same data.

    Your first goal is to understand the thread primitives used by this program, and to do some experiments to help you understand what really happens with multiple threads at runtime. To understand the execution path, trace through the code for the simple test case. See the notes in Tracing and Debugging Nachos Programs from the Duke equivalent of this course for some tips on how to do this.

    Specifically, run the nachos executable in gdb (be sure you are in the threads subdirectory):

    % gdb ./nachos

    Set a breakpoint in SimpleThread:

    (gdb) break _Z12SimpleThreadi

    Start running the program:

    (gdb) run

    Step through the program to see what happens during the execution:

    (gdb) n

    Continue to step through until you see "*** thread 1 looped 3 times" printed. Print out the stack for the current thread, and print the value of the variables "which" and "num":

    (gdb) where
    (gdb) print num
    (gdb) print which

    Copy the output of your session of running gdb on nachos and paste it into a file named project0.txt. Be sure to include all of the commands that you executed and all of the output generated. Email this file to Jose Garcia <j2garcia at cs.ucsd.edu> with subject CSE120: Project 0; by Tuesday, October 4th, at Midnight.


spacer gif
spacer gif
spacer gif
spacer gif
9500 Gilman Drive, La Jolla, CA 92093-0114
spacer gif
About CSE | CSE People | Faculty & Research | Graduate Education | Undergraduate Education
Department Administration | Contact CSE | Help | Search | Site map | Home
snoeren@cs.ucsd.edu
Official web page of the University of California, San Diego
Copyright © 2002 Regents of the University of California. All rights reserved.
spacer gif