0% found this document useful (0 votes)
96 views

Nachos Project Assignment 1: Multi-Programming TA: Hung-Leng Chen

This document provides instructions for installing and running the Nachos operating system on Linux. It outlines how to download Nachos, install a cross-compiler, compile Nachos, and run simple test programs. It also describes Assignment 1, which involves modifying Nachos code to correctly run two test programs simultaneously. Students are asked to tar and submit their modified Nachos source code along with a report by April 18th.

Uploaded by

Phat Quy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views

Nachos Project Assignment 1: Multi-Programming TA: Hung-Leng Chen

This document provides instructions for installing and running the Nachos operating system on Linux. It outlines how to download Nachos, install a cross-compiler, compile Nachos, and run simple test programs. It also describes Assignment 1, which involves modifying Nachos code to correctly run two test programs simultaneously. Students are asked to tar and submit their modified Nachos source code along with a report by April 18th.

Uploaded by

Phat Quy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

Nachos Project

Assignment 1

Multi-programming

TA: Hung-Leng Chen


Outline

Introduction to Nachos
Install Nachos on Linux
Assignment 1
Introduction

Nachos:
• Not Another Completely Heuristic Operating S
ystem
Written by Tom Anderson and his student
s at UC Berkeley
• http://www.cs.washington.edu/homes/tom/nachos/
Introduction (cont.)

An educational OS used to
• teaching monolithic kernel design and implem
entation
• doing experiments
A virtual MIPS machine
• User programs need a cross-compiler (target
MIPS)
Install Nachos
Platform: Linux , Linux over VMware or Cygwin
• Check gcc version
− gcc -v
• gcc 3.3.3 and gcc 3.2.2 are ok.
Install steps on Linux or Linux over VMware
• Get Nachos-4.0 << 作業公告 >>
• Get Cross Compiler << 作業公告 >>
• Move Cross Compiler to /
− mv ./mips-decstation.linux-xgcc.tgz /
• Untar Cross Compiler
− tar zxvf /mips-decstation.linux-xgcc.tgz
Install Nachos (cont.)

• Untar Nachos-4.0
− tar zxvf ./nachos-4.0.tar.gz
• Make Nachos-4.0
− cd./nachos-4.0/code
− make

• Test if installation is succeeded


− cd ./userprog
− ./nachos –e ../test/test1

• You should see the following…


You should see test1 resul
t
Total threads number is 1
Thread ../test/test1 is executing.
Print integer:9
Print integer:8
Print integer:7
Print integer:6
return value:0
No threads ready or runnable, and no pending interrupts.
Assuming the program completed.
Machine halting!

Ticks: total 200, idle 66, system 40, user 94


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
You should see test2 resul
t
Total threads number is 1
Thread ../test/test2 is executing.
Print integer:20
Print integer:21
Print integer:22
Print integer:23
Print integer:24
Print integer:25
return value:0
No threads ready or runnable, and no pending interrupts.
Assuming the program completed.
Machine halting!

Ticks: total 200, idle 32, system 40, user 128


Disk I/O: reads 0, writes 0
Operate Nachos

Nachos command help


• ./nachos -h
Debugging mode
• ./nachos -s
Execute files on Nachos
• ./nachos –e ../test/test1
Recompile Modified
Nachos Code

cd nachos-4.0/code
make clean (optional)
make
• If you want to fully re-compile the source cod
e, “make clean” is required. Or make will only
re-compile the modified and related files. (sav
e time)
Trace Nachos
Read *.h and *.cc to have an overview about
the whole system and see how it is
implemented.
Documentation (A Road Map Through
Nachos)
• http://www.cs.duke.edu/~narten/110/nachos/main/main.html

Trace for NachOS-4.0 with GLOBAL


• http://cc.ee.ntu.edu.tw/~farn/courses/OS2006/nachos/HTML/
Assignment 1
Go to nachos-4.0/code/userprog and type
“./nachos –e ../test/test1 –e ../test/test2”
Total threads number is 2
Thread ../test/test1 is executing.
Thread ../test/test2 is executing.
Print integer:9
Print integer:8
Print integer:7
Print integer:20
Print integer:21
Print integer:22
Print integer:23
Print integer:24
Print integer:6
Print integer:7
Print integer:8
Print integer:9
Print integer:10
Print integer:12
Print integer:13
Print integer:14
Print integer:15
Print integer:16
Print integer:16
Print integer:17
Print integer:18
Print integer:19
Print integer:20
Print integer:17
Print integer:18
Print integer:19
Print integer:20
Print integer:21
Print integer:21
Print integer:23
Print integer:24
Print integer:25
return value:0
Print integer:26
return value:0
No threads ready or runnable, and no pending interrupts.
Assuming the program completed.
Machine halting!

Ticks: total 800, idle 67, system 120, user 613


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

In some reasons, the output results didn’t


match the behavior of “../test/test1.c” and
“../test/test2.c”
Assignment 1(Hint)

Please trace the following files to see why


the output results are wrong
• nachos-4.0/code/userprog/addrspace.h
• nachos-4.0/code/userprog/addrspace.cc
• nachos-4.0/code/userprog/userkernel.cc
• nachos-4.0/code/machine/translate.h
• nachos-4.0/code/machine/translate.cc
Assignment 1(Hint)

Please modified the Nachos code to run the c


orrect results.
You may need to modify the following functi
ons
• Nachos-4.0/code/userprog/addrspace.cc
− constructor
− destructor
− initRegister
− Load
Deadline

4/18 Tue 14:00


Please tar your code and e-mail to [email protected]
e.ntu.edu.tw entitled as your_student_ID.tar.gz
• make clean (submit source code only)
• tar zcvf r92921100.tar.gz nachos-4.0
Accompany with your report about what d
id you done to the Nachos source code (w
hy and how) , or what did you get when t
racing the Nachos source code.
Grading policy

Note: your handout files must contain two p


arts
• 1.modified nachos source code (ID.tar.gz)
• 2.report
Correct result 30%
Report 70%
Contact me if you have any problems
[email protected]

You might also like