Nachos Project 4 Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/10/25.

Slides:



Advertisements
Similar presentations
Lectures on File Management
Advertisements

3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
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.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
CSCC69: Operating Systems
Chapter 7: User-Defined Functions II
CS162B: POSIX Threads Jacob Chan. Objectives ▪ Review on fork() and exec() – Some issues on forking and exec-ing ▪ POSIX Threads ▪ Lab 8.
Discussion Week 4 TA: Kyle Dewey. Overview Project #1 debriefing System calls Project #2.
Discussion Week 5 TA: Kyle Dewey. Overview HW 3.10 and 6.2 review Binary formats System call execution in NACHOS Memory management in NACHOS I/O in NACHOS.
1 Pointers A pointer variable holds an address We may add or subtract an integer to get a different address. Adding an integer k to a pointer p with base.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
The Process Model.
Processes CSCI 444/544 Operating Systems Fall 2008.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
1 CS 333 Introduction to Operating Systems Class 2 – OS-Related Hardware & Software The Process Concept Jonathan Walpole Computer Science Portland State.
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
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.
Chapter 6. 2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single Value Pass by Reference Variable Scope.
CSE 451 Section 4 Project 2 Design Considerations.
7/3/20151 Announcement (No deadline extension for the rest of quarter) Project 2 final deadline is Tuesday midnight May 19 Project 0 resubmission for autograding.
1 COMPSCI 110 Operating Systems Who - Introductions How - Policies and Administrative Details Why - Objectives and Expectations What - Our Topic: Operating.
Introduction to Processes CS Intoduction to Operating Systems.
CS1550 Assignment 5 Multiprogramming Implementation notes Matt Craven.
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.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Concurrent Programming. Concurrency  Concurrency means for a program to have multiple paths of execution running at (almost) the same time. Examples:
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
CS 346 – Chapter 4 Threads –How they differ from processes –Definition, purpose Threads of the same process share: code, data, open files –Types –Support.
CS162B: Pipes Jacob T. Chan. Pipes  These allow output of one process to be the input of another process  One of the oldest and most basic forms of.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Project 2: Initial Implementation Notes Tao Yang.
Nachos Tutorial Courtesy: University of Waterloo.
1 Threads Chapter 11 from the book: Inter-process Communications in Linux: The Nooks & Crannies by John Shapley Gray Publisher: Prentice Hall Pub Date:
8-Sep Operating Systems Yasir Kiani. 8-Sep Agenda for Today Review of previous lecture Process scheduling concepts Process creation and termination.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
System calls for Process management
CE Operating Systems Lecture 13 Linux/Unix interprocess communication.
© 2004, D. J. Foreman 1 Implementing Processes and Threads.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Operating Systems Process Creation
(a) What is the output generated by this program? In fact the output is not uniquely defined, i.e., it is not necessarily the same in each execution. What.
Discussion Week 2 TA: Kyle Dewey. Overview Concurrency Process level Thread level MIPS - switch.s Project #1.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Nachos Overview Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/09/18 Material Provided by Yuan-Hao Chang, Yung-Feng Lu.
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.
Nachos Project 3 Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/10/25.
Process Management Azzam Mourad COEN 346.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
System calls for Process management Process creation, termination, waiting.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
Nachos Project 2 Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/10/14 Material Provided by Yuan-Hao Chang, Yung-Feng Lu.
Direct memory access. IO Command includes: buffer address buffer length read or write dada position in disk When IO complete, DMA sends an interrupt request.
Lecturer: Hao-Hua Chu TA: Wen-Chang HSU.  Read and understand the nachos file system  Enhance file system in Nachos  Relax maximum size of a file.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Using Processes.
Chapter 3: Processes.
CGS 3763 Operating Systems Concepts Spring 2013
More examples How many processes does this piece of code create?
Operating Systems Lecture 6.
Tutorial: The Programming Interface
Lecture 6: Multiprogramming and Context Switching
CS510 Operating System Foundations
Presentation transcript:

Nachos Project 4 Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/10/25

2 Project 4 Design and implement appropriate support for multiprogramming Extend the system calls to handle process management and inter- process communication primitives

3 Summary Motivation & Objective Problems Goal 1~7 –1,2,7 10% % % Report –20% Submission

Motivation & Objective Nachos is currently an uni- programming environment Alter Nachos so that each process is maintained in its own system thread 4

Problem Take care of memory allocation and de-allocation Consider all the data and synchronization dependencies between threads. 5

Goal 1 Alter your exceptions to finish the thread instead of halting the system. This will be important, as a run time exception should not cause the operating system to shut down. Modify exception.cc 6

Goal 2 Implement multiprogramming. –The Nachos code is restricted to running one user program at a time. In order to convert the system from uni-programming to multiprogramming. Modify addrspace.h, addrspace.cc, and machine.h 7

Goal 2 You will need to: –A. Come up with a way of allocating physical memory frames so that multiple programs can be loaded into memory at once. –B. Properly handling freeing address space when a user program finishes. 8

Goal 2 –C. It is very important to alter the user program loader algorithm such that it handles frames of information. –Modify NumPhysPages (default 128) variable in machine.h You are not required to deal with limited memory space 9

Goal 3 Create table to store ProcessID (an integer) Implement the ProcessID Exec(char *name) system call. –Exec starts a new user program running within a new system thread. –Figure out how to set up user space inside a system thread. –Path name would be no longer than 256 bytes (including ‘\0’) 10

Goal 3 –Exec should return –1 on failure, else it should return the “ProcessID” of the user level program it just created –More like fork + exec in linux –Execute in /build.linux 11

Goal 4 Implement the int Join(ProcessID id) and void Exit(int exitCode) system calls. –Join will wait and block on a “Process ProcessID ” as noted in its parameter. –Exit returns an exit code to whomever is doing a join. 0 if a program successfully completes, another value if there is an error. 12

Goal 4 –The exit code parameter is set via the exitCode parameter. Join returns the exit code for the process it is blocking on, -1 if the join fails. –A user program can only join to processes that are directly created by the Exec system call. You can not join to other processes or to yourself. 13

Goal 4 –You will have to use semaphores inside your system calls to coordinate Joining and Exiting user processes. 14

Goal 5 Implement the int CreateSemaphore(char *name, int semval) system call. –Modify start.s and syscall.h to add the new system call signatures. –You will create a container at the system level that can hold upto 10 named semaphores. 15

Goal 5 –The CreateSemaphore system call will return 0 on success and –1 on failure. –The CreateSemaphore system call will fail if there are not enough free spots in the container, the name is null, the other semaphore with the same name already exists,or the initial semaphore value is less than 0. 16

Goal 6 Implement int wait(char *name) and int signal(char *name) system calls. –The name parameter is the name of the semaphore. 17

Goal 6 –Both system calls return 0 on success and –1 on failure. –Failure can occur if the user gives an illegal semaphore name (one that has not been created). 18

Goal 7 Sleeping Barber Problem is too difficult (You have to create IPC) So Many Producers to Many Consumers Problem is used to replace. You have to implement two user programs: Producer and Consumer 19

Goal 7 There are 3 kinds of resources: –A, B, C –Use semaphores named “A”, “B”, ”C” respectively Producer produce in a order: A, B, C for 10 times Consumers consume in a order C, B,A for 10 times 20

Goal 7 Producer will print its process ID and resource he creates on screen Consumer will print its process ID and resource he consumes on screen You have to create a system call GetProcessID() to get process ID in user program 21

Goal 7 Use your Print(), PrintNum() to print the output. Use semaphore to avoid interruption during each user program print its output for each line which describes process consumes or produces the resource 22

Goal 7 Output example: –1 produces A –2 produces A –1 produces B –1 produces C –3 consumes C –3 consumes B 23

Goal 7 We will use your CreateSemaphore to create three semaphore with name “A”, “B”, “C” to represent resource A, B, C Then use your Exec to call your two kinds of user program (at most 10 for each) for several time to test your program 24

25 Report Write a 2-page report –Don’t just paste your code, I’ll read it myself –Explain why your implementations would generate correct output –Describe meaningful problems you encountered and how you solved. If your project submission can’t compile and execute on Linux in Workstation Room 217, we will consider it as fail. –Please contact me to apply a workstation account if you need it.

26 Submission Two people in one group (Write down the name and student ID of all members in the report) The file you need to send: 1.A report in.pdf or.doc 2.All the Nachos directory Send your files –Tar your files to an archieve named: os_hw4_bXXXXXXXX_bOOOOOOOO.tar.gz – to with following title: [os_hw4] –Please follow the format carefully or our auto- reply system will not work tar zcvf os_hw4_bXXXXXXXX_bOOOOOOOO.tar.gz report.doc other files...

27 Submission (cont.) Deadline: 12/16 24:00 –For the delayed submission, deduct 5 points for each day DO NOT COPY!! Protect your code well!!