Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating System Tracing the nachos code in Java

Similar presentations


Presentation on theme: "Operating System Tracing the nachos code in Java"— Presentation transcript:

1 Operating System Tracing the nachos code in Java
Instructor: Dr. Lee, Hahn-Ming. (李漢銘 教授) TA (Reporter): Mao Ching-Hao 毛敬豪 2005/3/15

2 Overview What is Nachos? (Introduction, History, Architecture)
How to Set up the Nachos OS. Object-Oriented-Programming in Java (Interface, Abstract class, class) Booting Nachos Simulated Machine

3 What is Nachos?

4 What is Nachos? • An instructional operating system
• Includes many facets of a real OS: – Threads – Interrupts – Virtual Memory – I/O driven by interrupts • You can (and will) modify and extend it

5 What else is Nachos? • Nachos also contains some hardware simulation.
– MIPS processor • Can handle MIPS code in standard COFF, except for floating point instructions • You can (and will) write code in Java, compile it to MIPS and run it on Nachos. – Console – Network interface – Timer

6 Nachos In Java • Java much simpler than C++
• Java is type-safe – can’t write off the end of an array, easier to debug • Much easier and more reasonable to machine grade a Java project • More portable

7 Nachos Architecture

8 History of Nachos • Originally created here at Berkeley in 1992 in C++ (and a little assembly) • 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.

9 How to Setup the Nachos OS

10 You must download these files and toolkits
Nachos OS source Cygwin (Windows only) Java 2 Tool kits Cross Compilers

11 Recommend software You also can download these file to help your code tracing. It is free a free software, and not have heavy load for your computer.

12 Pay attention!! Cygwin should be install the gcc package.
In Cygwin, your should set jdk path in Cygwin. Please follow the nachos readme file to set up your environment. More Detail please see the Nachos readme.txt

13 Successfully This is proj 1 execute result

14 Object-Oriented-Programming in Java (Interface, Abstract class, class)

15 Java Object Oriented Language
You must take care the relation among the interface, abstract class and class. Besides the OO concepts, it is also important in Multi-Threads.

16 There are two kinds “method”
public void go(); //None implementation public void go(){ //implementation } Normal method Abstract method

17 Interface, Abstract class, class
All methods are abstract methods Is Interface All methods are not abstract methods Is class A part of methods are abstract, Another are normal methods. Is Abstract Class

18 Inner class, anonymous class
Let’s talk about the class’s architecture. Class Name Anonymous Class Attributes Inner Class Method

19 Pay Attention Tracing and design a Java program, the java API document is very important.

20 Booting Nachos

21 Booting Nachos • When you run Nachos, it starts in
nachos.machine.Machine.main • Machine.main initializes devices – interrupt controller, timer, MIPS processor, console, file system • Passes control to the autograder. • AutoGrader will create a kernel and start it (this starts the OS)

22 The Machine nachos.machine.Machine
• Kicks off the system, and provides access to various hardware devices: – Machine.interrupt() – Machine.timer() – Machine.console() – Machine.networkLink()

23 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

24 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.

25 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

26 Serial Console • Java interface nachos.machine.SerialConsole
• Contains methods: – readByte() returns one byte (or -1) and waits to interrupt when it has more – writeByte() takes one byte and waits to interrupt when its ready for more – setInterruptHandlers() tells the console who to call when it receives data or finishes sending data • Normally implemented by nachos.machine.StandardConsole, hooked up to stdin and stdout – Schedules read event every Stats.ConsoleTime ticks to polls stdin & invokes interrupt handler

27 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

28 The END ~Do you have any problem?


Download ppt "Operating System Tracing the nachos code in Java"

Similar presentations


Ads by Google