Nachos Tutorial - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Nachos Tutorial

Description:

Nachos Tutorial – PowerPoint PPT presentation

Number of Views:111
Avg rating:3.0/5.0
Slides: 18
Provided by: bcmiSj
Category:
Tags: hot | mail | msn | nachos | tutorial

less

Transcript and Presenter's Notes

Title: Nachos Tutorial


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
  • msnmarong_at_citiz.net
  • emailmarong1204_at_gmail.com
  • ?? 04 ACM
  • msnm-li_at_msn.com
  • ??? 04 ACM
  • msnsunsirius_at_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 Phase12
currentThread
KThread
8queen
Idle
cross compiler
merge
UThread
readyQueue
Scheduler
Kernel
merge
8queen
File System
Processor
Memory
.coff
JVM
Hardware
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
    dont 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?
Write a Comment
User Comments (0)
About PowerShow.com