Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nachos Tutorial 马 融 03-ACM Honor Class Dept. of Computer Science and Engineering Shanghai Jiao Tong University 2007 / 11.

Similar presentations


Presentation on theme: "Nachos Tutorial 马 融 03-ACM Honor Class Dept. of Computer Science and Engineering Shanghai Jiao Tong University 2007 / 11."— Presentation transcript:

1 Nachos Tutorial 马 融 03-ACM Honor Class Dept. of Computer Science and Engineering Shanghai Jiao Tong University 2007 / 11

2 Introduction to TA 马融 —— 03 ACM –msn : marong@citiz.net –email : marong1204@gmail.com 李沐 —— 04 ACM –msn : m-li@msn.com 孙晓锐 —— 04 ACM –msn : sunsirius@hotmail.com Course Homepage is –http://bcmi.sjtu.edu.cn/~nachos/

3 Outline What is Nachos? –Capabilities, purpose, history How does it work? How do I get started?

4 History of Nachos Originally created here at Berkeley in 1992 in C++ By Wayne A. Christopher, Steven J. Procter, and Thomas E. Anderson Used at many universities Rewritten in Java by Daniel Hettena –Now simpler, easier to grade, type-safe, portable, and more students now know Java.

5 What is Nachos? An instructional operating system? –Not definitely … Nachos is a virtual machine! –Written by java –Running on the JVM –Simulated a MIPS processor, fs, memory … –Provided an Unix-like system call to user program (including file operator and socket)

6 Illustrator of Phase1&2 JVM File System cross compiler ProcessorMemory SchedulerKernel merge8queen.coff merge8queen.cpp merge 8queen readyQueue “Hardware” currentThread Idle KThread UThread

7 Interface of Hardware package nachos.machine –Machine.java –Interrupt.java (phase 1) –TCB.java (phase 1) –Time.java (phase 1) –Processor.java (phase 2) –SerialConsole (phase 2) –FileSystem.java (phase 3) –NetwordLink.java (phase 4)

8 Interrupt Controller Kicks off hardware interrupts nachos.machine.Interrupt class maintains an event queue, clock Clock ticks under two conditions: –One tick for executing a MIPS instruction –Ten ticks for re-enabling interrupts After any tick, Interrupt checks for pending interrupts, and runs them. Calls device event handler, not software interrupt handler

9 Interrupt Controller (cont.) Important methods, accessible to other hardware simulation devices: –schedule() takes a time, handler –tick() takes a boolean (1 or 10 ticks) –checkIfDue() invokes due interrupts –enable() –disable() All hardware devices depend on interrupts - they don ’ t get threads.

10 Timer nachos.machine.Timer Hardware device causes interrupts about every 500 ticks (not exact) Important methods: –getTime() tells many ticks so far –setInterruptHandler() tells the timer what to do when it goes off Provides preemption

11 The Kernel Abstract class nachos.machine.Kernel Important methods –initialize() initializes the kernel, duh! –selfTest() performs test (not used by ag) –run() runs any user code (none for 1st phase) –terminate() Game over. Never returns. Each Phase will have its own Kernel subclass

12 Threading Happens in package nachos.threads All Nachos threads are instances of nachos.thread.KThread (or subclass) KThread has status –New, Ready, Running, Blocked, Finished Every KThread also has a nachos.machine.TCB Internally implemented by Java threads

13 Running threads Create a java.lang.Runnable(), make a Kthread, and call fork(). Example: class Sprinter implements Runnable { public void run() { // run real fast } Sprinter s = new Sprinter(); new KThread(s).fork();

14 TCB nachos.machine.TCB Thread Controller Block 428 lines of code (including comments) Very difficult, hard to understand… Sorry, I has forgotten the detail since last year…

15 Advice One step at a time. Get a little bit working. Then a little more. Then a little more, etc. Find a good tool, including a debugger, and use it. One choice - Eclipse.

16 Oracle When consider the nachos’ efficiency, you can slightly think the cost of kernel is nearly zero, all cost is belong to hardware simulator (e.f. we set the delay of disk to 100000ms…)

17 Any Question?


Download ppt "Nachos Tutorial 马 融 03-ACM Honor Class Dept. of Computer Science and Engineering Shanghai Jiao Tong University 2007 / 11."

Similar presentations


Ads by Google