Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

16
Nachos Project Nachos Project Assignment 1 Assignment 1 Multiprogramming Multiprogramming TA:mamafun TA:mamafun

Transcript of Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Page 1: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Nachos Project Nachos Project Assignment 1Assignment 1

MultiprogrammingMultiprogramming

TA:mamafunTA:mamafun

Page 2: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

OutlineOutline

►Introduction to NachosIntroduction to Nachos►Install Nachos on LinuxInstall Nachos on Linux►Assignment 1Assignment 1

Page 3: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

IntroductionIntroduction

►Nachos:Nachos: Not Another Completely Heuristic Not Another Completely Heuristic

Operating SystemOperating System

►Written by Tom Anderson and his Written by Tom Anderson and his students at UC Berkeleystudents at UC Berkeley

http://http://www.cs.washington.eduwww.cs.washington.edu/homes/tom/nachos//homes/tom/nachos/

Page 4: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Trace NachosTrace Nachos

►Get Nachos 4.0Get Nachos 4.0 http://cc.ee.ntu.edu.tw/~farn/courses/OS2004/index.htmlhttp://cc.ee.ntu.edu.tw/~farn/courses/OS2004/index.html

►C++ tutorialC++ tutorial http://www.cs.washington.edu/homes/tom/c++example/c++.pshttp://www.cs.washington.edu/homes/tom/c++example/c++.ps

►Read *.h and *.cc to have an overview about Read *.h and *.cc to have an overview about the whole system and see how it is the whole system and see how it is implemented.implemented.

►Documentation (A Road Map Through Documentation (A Road Map Through Nachos)Nachos) http://www.cs.duke.edu/~narten/110/nachos/main/main.htmlhttp://www.cs.duke.edu/~narten/110/nachos/main/main.html

Page 5: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Install NachosInstall Nachos

►Platform: Linux , Linux over VMware or Platform: Linux , Linux over VMware or CygwinCygwin Install steps on Linux or Linux over VMwareInstall steps on Linux or Linux over VMware

►Get Nachos-4.0Get Nachos-4.0►Get Cross CompilerGet Cross Compiler►Move Cross Compiler to /Move Cross Compiler to /

mv ./mips-decstation.linux-xgcc.tgz /mv ./mips-decstation.linux-xgcc.tgz /►Untar Cross CompilerUntar Cross Compiler

tar zxvf /mips-decstation.linux-xgcc.tgztar zxvf /mips-decstation.linux-xgcc.tgz►Untar Nachos-4.0Untar Nachos-4.0

tar zxvf ./nachos-4.0.tar.gztar zxvf ./nachos-4.0.tar.gz

Page 6: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Install Nachos (cont.)Install Nachos (cont.)

►Make Nachos-4.0Make Nachos-4.0 cd ./nachos-4.0/codecd ./nachos-4.0/code makemake

►Test if installation is succeededTest if installation is succeeded cd ./userprogcd ./userprog ./nachos –e ../test/test1./nachos –e ../test/test1

►You should see the following…You should see the following…

Page 7: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

You should seeYou should seeTotal threads number is 1Total threads number is 1Thread ../test/test1 is executing.Thread ../test/test1 is executing.Print integer:9Print integer:9Print integer:8Print integer:8Print integer:7Print integer:7Print integer:6Print integer:6return value:0return value:0No threads ready or runnable, and no pending interrupts.No threads ready or runnable, and no pending interrupts.Assuming the program completed.Assuming the program completed.Machine halting!Machine halting! Ticks: total 200, idle 66, system 40, user 94Ticks: total 200, idle 66, system 40, user 94Disk I/O: reads 0, writes 0Disk I/O: reads 0, writes 0Console I/O: reads 0, writes 0Console I/O: reads 0, writes 0Paging: faults 0Paging: faults 0Network I/O: packets received 0, sent 0Network I/O: packets received 0, sent 0

Page 8: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Operate NachosOperate Nachos

►Nachos command helpNachos command help ./nachos -h./nachos -h

►Debugging modeDebugging mode ./nachos -s./nachos -s

►Execute files on NachosExecute files on Nachos ./nachos –e ../test/test1./nachos –e ../test/test1

Page 9: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Recompile Modified Nachos Recompile Modified Nachos CodeCode

►cd nachos-4.0/codecd nachos-4.0/code►make clean (optional)make clean (optional)►makemake

If you want to fully re-compile the source If you want to fully re-compile the source code, “make clean” is required. Or make code, “make clean” is required. Or make will only re-compile the modified and will only re-compile the modified and related files. (save time)related files. (save time)

Page 10: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Assignment 1Assignment 1

► Go to nachos-4.0/code/userprog and type Go to nachos-4.0/code/userprog and type

““./nachos –e ../test/test1 –e ../test/test2”./nachos –e ../test/test1 –e ../test/test2”

Total threads number is 2Thread ../test/test1 is executing.Thread ../test/test2 is executing.Print integer:9Print integer:8Print integer:7Print integer:20Print integer:21Print integer:22Print integer:23Print integer:24Print integer:6Print integer:7

Page 11: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Print integer:8Print integer:9Print integer:10Print integer:12Print integer:13Print integer:14Print integer:15Print integer:16Print integer:16Print integer:16Print integer:16Print integer:17Print integer:17Print integer:18Print integer:18Print integer:19Print integer:19Print integer:20Print integer:20Print integer:17Print integer:17Print integer:18Print integer:18Print integer:19Print integer:19Print integer:20Print integer:20Print integer:21Print integer:21Print integer:21Print integer:21Print integer:23Print integer:23Print integer:24Print integer:24Print integer:25Print integer:25

Page 12: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

► In some reasons, the output results In some reasons, the output results didn’t match the behavior of didn’t match the behavior of “../test/test1.c” and “../test/test2.c”“../test/test1.c” and “../test/test2.c”

return value:0return value:0Print integer:26Print integer:26return value:0return value:0No threads ready or runnable, and no pending interrupts.No threads ready or runnable, and no pending interrupts.Assuming the program completed.Assuming the program completed.Machine halting!Machine halting! Ticks: total 800, idle 67, system 120, user 613Ticks: total 800, idle 67, system 120, user 613Disk I/O: reads 0, writes 0Disk I/O: reads 0, writes 0Console I/O: reads 0, writes 0Console I/O: reads 0, writes 0Paging: faults 0Paging: faults 0Network I/O: packets received 0, sent 0Network I/O: packets received 0, sent 0

Page 13: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Assignment 1Assignment 1

►Please trace the following files to see Please trace the following files to see why the output results are wrongwhy the output results are wrong nachos-4.0/code/userprog/addrspace.hnachos-4.0/code/userprog/addrspace.h nachos-4.0/code/userprog/addrspace.ccnachos-4.0/code/userprog/addrspace.cc nachos-4.0/code/userprog/userkernel.ccnachos-4.0/code/userprog/userkernel.cc nachos-4.0/code/machine/translate.hnachos-4.0/code/machine/translate.h Nachos-4.0/code/machine/translate.ccNachos-4.0/code/machine/translate.cc

Page 14: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Assignment 1Assignment 1

►Please modified the Nachos code to Please modified the Nachos code to run the correct results.run the correct results. You may need to modify the following You may need to modify the following

functionsfunctions►Nachos-4.0/code/userprog/addrspace.ccNachos-4.0/code/userprog/addrspace.cc

constructorconstructor destructordestructor initRegisterinitRegister LoadLoad

Page 15: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

DeadlineDeadline

► 4/9 Friday 6:004/9 Friday 6:00► Please tar your code and e-mail to Please tar your code and e-mail to

[email protected] entitled as [email protected] entitled as your_student_ID.tar.gzyour_student_ID.tar.gz

► make cleanmake clean► tar zcvf r92921076.tar.gz nachos-4.0tar zcvf r92921076.tar.gz nachos-4.0

accompany with your report about what accompany with your report about what did you done to the Nachos source code did you done to the Nachos source code (why and how) , or what did you get when (why and how) , or what did you get when tracing the Nachos source code.tracing the Nachos source code.

Page 16: Nachos Project Assignment 1 MultiprogrammingTA:mamafun.

Grading policyGrading policy

►Note: your handout files must contain Note: your handout files must contain two partstwo parts 1.modified nachos source code (ID.tar.gz)1.modified nachos source code (ID.tar.gz) 2.report2.report

►Correct resultCorrect result 30%30%►ReportReport 70%70%►Contact me if you have any any Contact me if you have any any

problemsproblems [email protected] [email protected] 電二 電二 219219