CS 162 Nachos Tutorial Image courtesy of Thomas Andersen:

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Chapter 2 Operating System Overview Operating Systems: Internals and Design Principles, 6/E William Stallings.
WHAT IS AN OPERATING SYSTEM? An interface between users and hardware - an environment "architecture ” Allows convenient usage; hides the tedious stuff.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
Operating System Tracing the Nachos code in Java Instructor: Dr. Lee, Hahn-Ming. ( 李漢銘 教授 ) TA (Reporter): Mao, Ching-Hao 毛敬豪 Chen, Wei-Da 陳威達 2006/3/14.
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
1: Operating Systems Overview
OPERATING SYSTEM OVERVIEW
Operating System Tracing the nachos code in Java
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
1/28/2004CSCI 315 Operating Systems Design1 Operating System Structures & Processes Notice: The slides for this lecture have been largely based on those.
Figure 1.1 Interaction between applications and the operating system.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
1/23/2008CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
OS Concepts An Introduction operating systems. At the end of this module, you should have a basic understanding of what an operating system is, what it.
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
Preemptive Scheduling Vivek Pai / Kai Li Princeton University.
Operating Systems Nachos Project 2 Thread Scheduling.
Welcome to the World of Nachos CPS 110 Spring 2004 Discussion Session 1.
LOGO OPERATING SYSTEM Dalia AL-Dabbagh
Operating System Review September 10, 2012Introduction to Computer Security ©2004 Matt Bishop Slide #1-1.
Nachos Phase 1 Code -Hints and Comments
Threads Many software packages are multi-threaded Web browser: one thread display images, another thread retrieves data from the network Word processor:
Nachos Projects Overview and Project 1 TA : 吳哲榮 2010/10/21.
Operating Systems Lecture 2 Processes and Threads Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Nachos Projects Overview and Project 1 TA : 王映智 2007/10/24.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008.
CS 346 – Chapter 4 Threads –How they differ from processes –Definition, purpose Threads of the same process share: code, data, open files –Types –Support.
NT Kernel CS Spring Overview Interrupts and Exceptions: Trap Handler Interrupt Request Levels and IRT DPC’s, and APC’s System Service Dispatching.
Nachos Tutorial 马 融 03-ACM Honor Class Dept. of Computer Science and Engineering Shanghai Jiao Tong University 2007 / 11.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
1: Operating Systems Overview 1 Jerry Breecher Fall, 2004 CLARK UNIVERSITY CS215 OPERATING SYSTEMS OVERVIEW.
1. Introduction to Nachos Shandong University 2014 秋.
CS140 Project 1: Threads Slides by Kiyoshi Shikuma.
Nachos Project Assignment 1 Multi-programming TA: Hung-Leng Chen.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
Nachos Lecture 2 Xiaorui Sun. Phase 2 You have got one machine (machine package) You have to implements the incomplete OS (userprog package) Run programs.
Threads versus Events CSE451 Andrew Whitaker. This Class Threads vs. events is an ongoing debate  So, neat-and-tidy answers aren’t necessarily available.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
1 Lecture 6 “Nachos” n nachos overview n directory structure n nachos emulated machine n nachos OS n nachos scheduler n nachos threads.
I/O Software CS 537 – Introduction to Operating Systems.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
S ALVATORE DI G IROLAMO (TA) Networks and Operating Systems: Exercise Session 1.
CSE120 Discussion 5 Xinxin Jin. Where Are We?  Now we have finished some thread mechanisms to support Nachos kernel  Next, we want to enable user-level.
Introduction to Operating Systems Concepts
Introduction to Operating Systems
Operating Systems CMPSC 473
CS 6560: Operating Systems Design
Mechanism: Limited Direct Execution
CS 3305 System Calls Lecture 7.
Real-time Software Design
Chapter 3: Windows7 Part 2.
Introduction to Operating Systems
Intro. To Operating Systems
Chapter 3: Windows7 Part 2.
Operating Systems.
Lecture Topics: 11/1 General Operating System Concepts Processes
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Interrupts and System Calls
In Today’s Class.. General Kernel Responsibilities Kernel Organization
Presentation transcript:

CS 162 Nachos Tutorial Image courtesy of Thomas Andersen:

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

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

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 C, compile it to MIPS and run it on Nachos. –Console –Network interface –Timer

Why Nachos? What better way to learn how an OS works than by building one? Much easier and more reasonable to build a simulated one in Java Skeleton code allows us to work on, replace, or upgrade one piece at a time.

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.

How are we using it? Four Nachos assignments - “Phases” Phase 1 - Threading Phase 2 - Multiprogramming Phase 3 - Caching and Virtual Memory Phase 4 - Networks and Distributed Systems

How does Nachos work? Entirely written in Java Broken into Java packages: –nachos.ag (autograder classes) –nachos.machine (most of the action) –nachos.network (Phase 4) –nachos.security (tracks priviledge) –nachos.threads (Phase 1) –nachos.userprog (Phase 2) –nachos.vm (Phase 3)

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)

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

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

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.

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

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

Other Hardware Devices Disk –Didn’t make the jump to Java from C++, we don’t use it for our Nachos assignments Network Link –Similar to console, but packet based. –Used for Phase 4. –You should be able to figure it out by then.

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 Oh, how I hated the kernel, with his wee beady eyes, and smug look on his face! “Oh, you’re gonna buy my chicken!”

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

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();

Scheduler Some subclass of nachos.machine.Scheduler Creates ThreadQueue objects which decide what thread to run next. Defaults to RoundRobinScheduler Specified in Nachos configuration file

Nachos Configuration nachos.conf file lets you specify many options –which clases to use for Kernel, Scheduler –whether to be able to run user progs –etc. Different one for each project.

How to get started Go to class web page Download and install nachos package Read the README, make sure you can make proj1 OK The first phase will be posted soon with detailed instructions for first Nachos assignment

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.

For More Information README file in the installation has lots of good stuff See the Class Web Page for intros, background, and the code itself. Read the code! You can see exactly what is going on.