Nachos.

Slides:



Advertisements
Similar presentations
Installing DOS and Windows98 under MS Virtual PC.
Advertisements

Operating Systems: Monitors 1 Monitors (C.A.R. Hoare) higher level construct than semaphores a package of grouped procedures, variables and data i.e. object.
Practice Session 7 Synchronization Liveness Deadlock Starvation Livelock Guarded Methods Model Thread Timing Busy Wait Sleep and Check Wait and Notify.
CSCC69: Operating Systems
EEE 435 Principles of Operating Systems Interprocess Communication Pt II (Modern Operating Systems 2.3)
Interprocess Communication
CY2003 Computer Systems Lecture 05 Semaphores - Theory.
Concurrency (3) CSE 132. iClicker/WUTexter Question The following four numbers are in 8-bit 2’s complement form: Which.
CS 162 Discussion Section Week 3. Who am I? Mosharaf Chowdhury Office 651 Soda 4-5PM.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L19 (Chapter 24) Multithreading.
Avishai Wool lecture Introduction to Systems Programming Lecture 4 Inter-Process / Inter-Thread Communication.
1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
Building Web Pages With Microsoft Office. Introduction This tutorial is for the beginning web builder. It utilizes software that you already have, Microsoft.
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
Concurrency: Mutual Exclusion, Synchronization, Deadlock, and Starvation in Representative Operating Systems.
22-Jun-15 Threads and Multithreading. 2 Multiprocessing Modern operating systems are multiprocessing Appear to do more than one thing at a time Three.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Monitors CSCI 444/544 Operating Systems Fall 2008.
Synchronization in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Fundamentals of Python: From First Programs Through Data Structures
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 21: Publishing Your Pages on the Web.
Creating a Web Page HTML, FrontPage, Word, Composer.
Discussion Week 3 TA: Kyle Dewey. Overview Concurrency overview Synchronization primitives Semaphores Locks Conditions Project #1.
1 Web Server Administration Chapter 9 Extending the Web Environment.
CSN08101 Digital Forensics Lecture 1B: Essential Linux and Caine Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak.
Nachos Phase 1 Code -Hints and Comments
Windows Programming Using C# Threading. 2 Contents Threading Thread class Interlocked class Monitor class Semaphore class Thread Pools.
12/1/98 COP 4020 Programming Languages Parallel Programming in Ada and Java Gregory A. Riccardi Department of Computer Science Florida State University.
FTP Server and FTP Commands By Nanda Ganesan, Ph.D. © Nanda Ganesan, All Rights Reserved.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Introduction to Concurrency.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Classical problems.
Java Threads. What is a Thread? A thread can be loosely defined as a separate stream of execution that takes place simultaneously with and independently.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
Creating Programs on UNIX This term you can create programs on UNIX or you can create programs using a C++ compiler on your PC. This set of slides steps.
Advanced Concurrency Topics Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
CS140 Project 1: Threads Slides by Kiyoshi Shikuma.
Discussion Week 2 TA: Kyle Dewey. Overview Concurrency Process level Thread level MIPS - switch.s Project #1.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Concurrency & Dynamic Programming.
FTP Using FileZilla CS10001 – Computer Literacy. Step 1: Understanding the Interface Quickconnect Bar Message Log Area Local site navigation (either lab.
How to use WS_FTP A Step by Step Guide to File Transfer.
Multithreaded programming  Java provides built-in support for multithreaded programming. A multithreaded program contains two or more parts that can run.
Monitors CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Problems with Semaphores Used for 2 independent purposes –Mutual exclusion –Condition synchronization Hard to get right –Small mistake easily leads to.
Processes Creation and Threads. Shared Resource Example The console is just a place where text can be printed by the application currently running. Program.
FTP COMMANDS OBJECTIVES. General overview. Introduction to FTP server. Types of FTP users. FTP commands examples. FTP commands in action (example of use).
1 Previous Lecture Overview  semaphores provide the first high-level synchronization abstraction that is possible to implement efficiently in OS. This.
Implementing Lock. From the Previous Lecture  The “too much milk” example shows that writing concurrent programs directly with load and store instructions.
June 11, 2002Serguei A. Mokhov, 1 The Monitor COMP346 - Operating Systems Tutorial 7 Edition 1.2, June 15, 2002.
CSC CSC 143 Threads. CSC Introducing Threads  A thread is a flow of control within a program  A piece of code that runs on its own. The.
© 2004, D. J. Foreman 1 Monitors and Inter-Process Communication.
© 2004, D. J. Foreman 1 Monitors and Inter-Process Communication.
3/17/2016cse synchronization-p2 © Perkins, DW Johnson and University of Washington1 Synchronization Part 2 CSE 410, Spring 2008 Computer.
Homework-6 Questions : 2,10,15,22.
Concurrency in Java MD. ANISUR RAHMAN. slide 2 Concurrency  Multiprogramming  Single processor runs several programs at the same time  Each program.
Implementing Mutual Exclusion Andy Wang Operating Systems COP 4610 / CGS 5765.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Mutual Exclusion Mutexes, Semaphores.
MULTITHREADED PROGRAMMING Processes vs. Threads Process states and state transitions Hazards and Semaphores 1.
Tutorial 2: Homework 1 and Project 1
Creating Programs on UNIX
Lecture 14: Pthreads Mutex and Condition Variables
Multithreading.
Multithreading.
Implementing Mutual Exclusion
Implementing Mutual Exclusion
Lecture 14: Pthreads Mutex and Condition Variables
“The Little Book on Semaphores” Allen B. Downey
Monitors and Inter-Process Communication
Presentation transcript:

Nachos

Getting the Source Code -See CVS quickstart on COSC3407 website. On windows use putty: In the computer lab: -> start -> Math and computer science -> internet applications -> putty or open dos window: p: -> cd putty -> putty type nachos.cs.laurentian.ca in host name box. - you get a warning message the 1st time -you can ignore it (click yes). Sign on. follow instructions from cvs quickstart. -Need group number -these are listed on the course website under project groups.

Moving files can use ftp to move files to and from your pc. ftp nachos.cs.laurentian.ca You will be prompted to enter a user name and password. Once signed in you can use cd to change directories, dir or ls to list the directory, pwd to show the current directory. Use get filename to move a file from the current directory on the remote system to the current directory on the local system. Use put filename to move a file from the current directory on the local system to the current directory on the remote system. Can use mget *.* to get an entire directory.

There are also some sample design documents on the course web site. Nachos Source Code The code for nachos is in the directory groupx/nachos (x is your group number). All the code that will be changed in project 1 is in the threads subdirectory (groupx/nachos/threads). You may also want to look at the machine subdirectory (if you are ambitious). This implements the nachos virtual machine. There are also some sample design documents on the course web site.

Project 1: Go to project phases -> project1 on the course website to get a description of the project. Read this section very carefully.

Task 1: The task requires you to modify the KThread.java class. If you look at the source code you will see that the join method has not been implemented. The task is to implement this method. You also have to make modifications to at least one other method. For example, suppose 2 threads t1 and t2 have been created. If thread t1 has the line t2.join(), this means that thread t1 will stop processing until thread t2 has completed. A thread can be in 1 of 4 states: new, ready, running, blocked or finished. To avoid busy waiting, the waiting thread should be in the blocked state (look at the sleep method). You then need some way to "wake up" the blocked thread (t1) when thread t2 finishes.

Creating threads To create and run a thread: final KThread KThreadA, KThreadB, KThreadC; … KThreadD = new KThread(new Runnable(){ public void run() { System.out.println("THREAD D STARTED"); for(int i = 0; i < 100000000; i++) {} KThreadE.join(); System.out.println("THREAD D FINISHED"); } }); To run: KThreadD.fork(); Described in Guide to Nachos on course website under link Nachos for Java Walkthrough.

Task2 There is a file Condition2.java in the threads directory. This program has the methods you need to implement – it’s just a shell. Look at Condition.java which implements the condition variables using semaphores. The task is to implement condition variables without using semaphores. To do this task you should understand both condition variables and semaphores. Look at the code in Semaphore.java.

Task2 (Condition Variables) Condition variable: Has an associated lock to make sure only one process is active in the critical region at a time. A thread must acquire the lock to enter the critical region. The condition variable allows a thread to wait for a condition to become true while in the critical region. If the condition is not true the thread can "sleep" in the critical region and allow another process to enter. This thread may change the condition to true and wake a thread that is currently sleeping on the condition. The awakened thread is moved to the ready queue (mesa semantics). This means it does not run right away. The awakened thread will try to required the lock and proceed. It must check the condition again to make sure it is still true.

Task 2 -Methods void sleep() This method atomically released the lock and puts itself to sleep. On waking it needs to require the lock. void wake() This method wake one thread (if there is one) that are sleeping on the condition. void wakeAll() Wakes all threads sleeping on this condition. **note** All methods require that the thread hold the lock.

Task 3 Complete the alarm class The task is to implement the waitUntil(int x) method in Alarm.java We want to make the calling thread to block -i.e. move to the wait queue. The thread should be woken when the interval specified on the call is over (within 500 ticks). The timerInterrupt() method in this class is called every 500 ticks.To get the current time: long curTime =Machine.timer().getTime();

Task 4: Implement the Communicator class. 2 methods to implement, void speak(int word) and int listen(). The message (word) is passed from the speaker to exactly one listener. If there are no listeners the speaker must wait for one. For example if 3 speaker threads are run first, they will all wait until listeners arrive. If then 3 listener threads arrive then each will pick up a different word from each of the three speakers. As soon as their word is transferred the speaker and listener exit the system. Conversely, if listeners arrive before speakers, they must also wait. The documentation suggests that this can be done with one condition variable. Note that there should never be listeners and speakers waiting at the same time.

Task 5 Implement ReactWater. Somewhat similar to Communicator. In this case 2 hydrogen, and one oxygen. Each thread will either be a hydrogen thread (call hReady()) or an oxygen thread (call oReady()). As soon as 2 hydrogen threads and one oxygen thread are ready, makeWater() can be called and those threads can exit. For example, if 3 oxygen threads are created and 4 hydrogen, 2 water molecules can be created, and 1 oxygen molecule should be left waiting. No thread should be part of 2 different water molecules.