Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nachos Overview Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/09/18 Material Provided by Yuan-Hao Chang, Yung-Feng Lu.

Similar presentations


Presentation on theme: "Nachos Overview Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/09/18 Material Provided by Yuan-Hao Chang, Yung-Feng Lu."— Presentation transcript:

1 Nachos Overview Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/09/18 Material Provided by Yuan-Hao Chang, Yung-Feng Lu

2 2 Nachos Nachos: – Not Another Completely Heuristic Operating System Written by Tom Anderson and his students at UC Berkeley http:// www.cs.washington.edu/homes/tom/nachos / http:// www.cs.washington.edu/homes/tom/nachos /

3 3 Nachos 4.0 An educational OS used to –teach kernel design and implementation –do experiments Fact: –Real hardware is difficult to handle. –May break if handled wrong. Approach: –Use a virtual MIPS machine –Provide some basic OS elements

4 4 Nachos 4.0

5 5 Simulates MIPS architecture on host system (Unix /Linux/ Windows / MacOS X ) User programs need a cross-compiler (target MIPS) –Eg. To compile user programs to MIPS on Linux Nachos appears as a single threaded process to the host operating system

6 6 Designated Platform in This Class Linux in Workstation Room 217 –Installation guide http://mll.csie.ntu.edu.tw/course/os_f08/ 217.htm http://mll.csie.ntu.edu.tw/course/os_f08/ 217.htm If your project submission can’t execute on Linux in Workstation Room 217, we will consider it as fail. –The Linux kernel in Workstation Room 217 is 2.6.26. –Please contact me to apply a workstation account if you need it.

7 7 How does it work?

8 8 How does it work? (Cont.)

9 9 How does it work? (Cont..)

10 10 Setup the System Refer to the following document: http://mll.csie.ntu.edu.tw/course/os_f08/217.h tm http://mll.csie.ntu.edu.tw/course/os_f08/217.h tm You need: –Nachos source code –MIPS Cross compiler –A patch for Nachos to work on 217 workstations

11 11 Nachos content

12 12 Setup the System (cont.) You can build Nachos on Linux –Your linux –Virtual machine –217 linux (1~14) (recommended) 217 runs 64-bit machines –Apply the patch before you build anything

13 13 Setup the System (cont.) MIPS Cross compiler –Nachos simulates MIPS machine –The user program built by this compiler cannot run on Linux Please make sure that you follow the steps in the instruction –You should extract Nachos and the cross compiler to the same directory (NachOS-4.0 and usr) –Or, user programs could not be built

14 14 Test files There are some test user programs in NachOS-4.0/code/test/ –Use “make” to build them, the MIPS binary would be generated in the same directory Use these files to test if your Nachos is properly modified and built

15 15 How to run “nachos –x userprog –d u” –Nachos binaries is in NachOS- 4.0/code/build.linux/nachos –Use –x to run the user programs –Use –d to show debug messages A full list of options is under NachOS- 4.0/code/lib/debug.h Nachos would startup, load and run the user program, then halt

16 16 GLOBAL A source code tag system for you to trace large source files (Eg. Nachos) Useful for hacking a large project containing many subdirectories, many #ifdef and many main() functions. You can download GLOBAL from http://www.gnu.org/software/global/do wnload.html http://www.gnu.org/software/global/do wnload.html

17 17 GLOBAL (Cont.) How To Start? –http://www.gnu.org/software/global/download.ht mlhttp://www.gnu.org/software/global/download.ht ml –Installation %./configure % make % make install Two utilities –gtags, htags

18 18 GLOBAL (Cont..) gtags – Create Tag Database % cd NachOS-4.0/ % gtags htags – Create Hypertext Files (under HTML/) for a Web-Based Interface for Global % htags –Ff The GLOBAL for NachOS-4.0 http://www.csie.ntu.edu.tw/~artoo/NachOS- 4.0/HTML/ http://www.csie.ntu.edu.tw/~artoo/NachOS- 4.0/HTML/

19 19 How to Start Trace Codes Read interfaces in the *.h files first. –To have overview of the whole system. Then, read the implementations in the *.cc files. –See how the executable code supports each interface. Documentation –http://www.cs.duke.edu/~narten/110/nachos/main/ main.htmlhttp://www.cs.duke.edu/~narten/110/nachos/main/ main.html

20 20 C++ Object-Oriented Looks like JAVA, based on C C  C++ C++ has lots of features, but Nachos only uses a few –So take it easy

21 21 C++ Class Declaration (Usually in header files) class CoffeCup { private: // or protected, these members can only be // accessed by CoffeeCup members int max_volume, current; char name[100]; bool checkVolume (void); public: // these members can be accessed by anyone CoffeeCup (char * new_name); // constructor ~CoffeeCup (); // destructor int fill (int vol); int drink (int vol); };

22 22 C++ Class (cont.) Definition (Usually in.cc or.cpp files) CoffeeCup::CoffeeCup (char *new_name) : max_volume(100), current(0) { strcpy(name, new_name); } CoffeeCup::~CoffeeCup () { if(current > 0) cout << “You left ” << current << “ in the cup ” << name << endl; } bool CoffeeCup::checkVolume (void) { return (current <= max_volume); }

23 23 C++ Class (cont.) void CoffeeCup::fill (int vol) { current += vol; if(!checkVolume()) { cout << “Too much!” << endl; current = max_volume; } void CoffeeCup::drink (int vol) { current -= vol; if(current < 0) current = 0; }

24 24 C++ Class (cont.) // We demonstrate the difference between an object and // a pointer to object CoffeeCup cup1(“Espresso”); CoffeeCup *cup2 = new CoffeeCup(“Latte”); cup1.fill(50); cup2->fill(60); cup1.drink(30); (*cup2).drink(30); // Delete or we’ll have memory leak delete cup2; // Now cup1 has 20, cup2 has 30

25 25 Other features Dynamic allocated array char *array = new char[100]; array[0] = … delete [] array; “this” –A pointer point to the class instance itself –“checkVolumne()” is equal to “this->checkVolume()” ASSERT(…) –Check if the condition is meet. Abort if it is not. –Not really a C++ feature, though ASSERTNOTREACHED( ) –Check if this line is not executed –Eg. placed after a “return” Feel free to ask me if you have C++ problems


Download ppt "Nachos Overview Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/09/18 Material Provided by Yuan-Hao Chang, Yung-Feng Lu."

Similar presentations


Ads by Google