<- back

CS 153: Project 0: Introduction to Nachos

Nachos is a Java application written to perform the functions of a real operating system. All the details of how the operating system implements concepts such as threading, virtual memory, and processes are exposed to you. All the source code implementing the Nachos operating system is included with the distribution. However, this distribution is incomplete insofar as some of the concepts are not fully implemented. Your job will be to complete the missing portions of the operating system and use the functionality in your projects.

The first step is to understand the environment. You'll want to download a copy of the Nachos distribution from the main page to your home directory.

The second step is to read the README file in the base directory of the Nachos distribution. This will explain how to alter your path to run Nachos from the command line. There will be other information in the README file for future projects. Don't worry about that right now.

After installing the Nachos distribution and setting up your environment variables, run the program nachos (in the proj0 subdirectory) for a simple test of our code. This causes the methods of nachos.threads.ThreadedKernel to be called in the order listed in threads/ThreadedKernel.java:

  1. The ThreadedKernel constructor is invoked to create the Nachos kernel.
  2. This kernel is initialized with initialize().
  3. This kernel is tested with selfTest().
  4. This kernel is finally "run" with run(). For now, run() does nothing, since our kernel is not yet able to run user programs.
Your session should match the following:
$ cd nachos/proj0
$ make
$ ./../bin/nachos
nachos 5.0j initializing... config interrupt timer user-check grader
*** 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
Machine halting!

Ticks: total 2130, kernel 2130, user 0
Disk I/O: reads 0, writes 0
Console I/O: reads 0, writes 0
Paging: page faults 0, TLB misses 0
Network I/O: received 0, sent 0

Trace the execution path by hand to find where the output is coming from (i.e. which classes are generating those output statements). Your job will be simple for this first project, simply adding another print statement as described below. But first, some general information.

Your project code will be automatically graded. There are two reasons for this:

  1. An autograder can test your code a lot more thoroughly than a TA can, yielding more fair results.
  2. An autograder can test your code a lot faster than a TA can.

Of course, there is a downside. Everything that will be tested needs to have a standard interface that the autograder can use, leaving slightly less room for you to be creative. Your code must strictly follow these interfaces (the documented *Interface classes).

Since your submissions will be processed by a program, there are some very important things you must do, as well as things you must not do.

For all of the projects in this class...

  1. Do not modify Makefile, except to add non-java source files (useful in later projects). We will be using our own Makefile. (javac automatically finds source files to compile, so we don't need you to submit Makefile).
  2. Only modify nachos.conf according to the project specifications. We will also being using our own nachos.conf file. Do not rely on any additional keys being in this file.
  3. Do not modify any classes in the nachos.machine package, the nachos.ag package, or the nachos.security package. Also do not add any classes to these packages. They will not be used during grading.
  4. Do not add any new packages to your project. All the classes you submit must reside in the packages we provide.
  5. Do not modify the API for methods that the autograder uses. This is enforced every time you run Nachos by Machine.checkUserClasses(). If an assertion fails there, you'll know you've modified an interface that needs to stay the way it was given to you.
  6. Do not directly use Java threads (the java.lang.Thread class). The Nachos security manager will not permit it. All the threads you use should be managed by TCB objects (see the documentation for nachos.machine.TCB).
  7. Do not use the synchronized keyword in any of your code. We will grep for it and reject any submission that contains it.
  8. Do not directly use Java File objects (in the java.io package). In later projects, when we start dealing with files, you will use a Nachos file system layer.
When you want to add non-java source files to your project, simply add entries to your Makefile.

In this project,

  1. You will not need to add any new files.

Tasks:

  1. (100%)

    Change the Nachos output print statements

    *** thread n looped m times

    to

    *** awesome thread n looped m times

    That's it. Be sure to test your changes before you submit them.

Code Submission:

As with all projects, you will submit it using iLearn. For this project, you cannot work in a group. Each student must submit their own project 0.
You will have until the posted due date to submit this project.