CS1550 Assignment 5 Multiprogramming Implementation notes Matt Craven.

Slides:



Advertisements
Similar presentations
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Advertisements

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
Memory Management Questions answered in this lecture: How do processes share memory? What is static relocation? What is dynamic relocation? What is segmentation?
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Processes CSCI 444/544 Operating Systems Fall 2008.
Multiprocessing Memory Management
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.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
Operating Systems Lecture # 3. Recap Hardware Operating System Application System Call Trap Hardware Trap Processor.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Computer Organization and Architecture
CS415 Minithreads Project 2 Context Switch and Stack Initialization Ken Hopkinson
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
Virtual Memory.
System Calls 1.
Welcome to the World of Nachos CPS 110 Spring 2004 Discussion Session 1.
Protection and the Kernel: Mode, Space, and Context.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
1 I-Logix Professional Services Specialist Rhapsody IDF (Interrupt Driven Framework) CPU External Code RTOS OXF Framework Rhapsody Generated.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Chapter 1 Process and Thread. 1.2 process The address space of a program – Text – Code – Stack – Heap A set of registers – PC – SP Other resources – Files.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
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.
Project 2: Initial Implementation Notes Tao Yang.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Nachos Tutorial Courtesy: University of Waterloo.
1 Threads, SMP, and Microkernels Chapter Multithreading Operating system supports multiple threads of execution within a single process MS-DOS.
CS140 Project 1: Threads Slides by Kiyoshi Shikuma.
Lecture 5 Page 1 CS 111 Online Processes CS 111 On-Line MS Program Operating Systems Peter Reiher.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Multi-Tasking The Multi-Tasking service is offered by VxWorks with its real- time kernel “WIND”.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Processes and Virtual Memory
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.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
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.
NachOS Threads System Road Map through the Code Lab 3.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Nachos Project Assignment 3 Memory Management
CS 140 Lecture Notes: Virtual Memory
Process Management Process Concept Why only the global variables?
CS 6560: Operating Systems Design
A Real Problem What if you wanted to run a program that needs more memory than you have? September 11, 2018.
Intro to Processes CSSE 332 Operating Systems
Process management Information maintained by OS for process management
Structure of Processes
CS 140 Lecture Notes: Virtual Memory
Threads, SMP, and Microkernels
More examples How many processes does this piece of code create?
CS 140 Lecture Notes: Virtual Memory
Operating Systems.
Lecture Topics: 11/1 General Operating System Concepts Processes
CPU scheduling decisions may take place when a process:
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Lecture 6: Multiprogramming and Context Switching
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Process Description and Control in Unix
CS703 – Advanced Operating Systems
CS 140 Lecture Notes: Virtual Memory
CS Introduction to Operating Systems
Presentation transcript:

CS1550 Assignment 5 Multiprogramming Implementation notes Matt Craven

Multiprogramming The goal of this project is to take the given Nachos code, which supports single tasks, and modify it so that multiple tasks can run simultaneously Use preemption Round-robin scheduling

Nachos Scheduler The Nachos scheduler already supports multiple kernel threads (Thread class) Threads can Yield to each other Scheduler is FIFO No preemption

Round robin scheduling Round robin scheduling runs tasks in the order they are submitted A fixed quantum is used for each process When the quantum expires, the current task yields the processor, and the next process is selected from the head of the ready queue The yielding task is put at the end of the ready queue

Round robin in Nachos As you may have noticed, round robin is simply FIFO scheduling with preemption You simply need a way to preempt a process based on a fixed timer interrupt Use the built-in Timer class

Nachos Timer Nachos uses a timer interrupt when you enable the -rs flag (remember project 2?) This turns on a random timer interrupt See the line in system.cc that looks like this: –Timer = new Timer(TimerInterruptHandler, 0, randomYield) You want a non-random timer interrupt

Nachos Timer Study the code from system.cc in the last slide, and pay attention to what it does, how you declare a timer, and what TimerInterruptHandler does Your timer can be created with one line of code similar to one in the last slide

Starting a Nachos Process When you start nachos with the -x argument and an executable file name, it will call the StartProcess() function in userprog/progtest.cc Pay close attention to what StartProcess does You will need to modify this code

StartProcess Remember that when you start Nachos, it automatically creates a “main” kernel thread that takes care of initializing Nachos and running the user program, turning on debugging, etc. StartProcess initializes a new AddrSpace for the executable, and then executes machine->Run()

StartProcess Take a look at the comments for the machine->Run() line Notice that when you call this method, it never returns Not good! If you can only call StartProcess once, you can only run one program at a time

StartProcess StartProcess is run within the “main” kernel thread StartProcess needs to return so that if there is another program to be run, we can call StartProcess again Solution: create a new thread for each user program so that the “main” thread can be used to call StartProcess more than once

More in StartProcess StartProcess performs a few tasks other than calling machine->Run() Calls AddrSpace() to set up an address space for the executable Sets up register values for your executable - be careful, how this is done will change when you start creating your own threads!

AddrSpace() Even though we’re not using virtual memory for this assignment, we still need a page table for each executable This saves us the trouble of worrying about PIDs and memory protection When threads are context-switched, the page table from the thread we switch to is used

AddrSpace Since we have essentially unlimited physical memory in this assignment, you need to worry about which physical pages are free You may use a bitmap for this You need to load the code and data from the executable like the last assignment

AddrSpace You also need to make sure that your addrspace has numPages of physical pages associated with it (ie, used in the pageTable) to hold all the code, data, uninitData and stack space You will set up your page table statically: each page in the pageTable will point to a valid physical page

AddrSpace IMPORTANT: When loading code and data from the executable into physical memory: –The last page of code will probably not be full, so that the last page of code will share space with the first page of initData –The last page of initData will also probably not be full, so it will be shared with the first page of uninitData

System call support You are also required to implement system call handlers (in exception.cc) for the Open, Read and Write system calls For this, you simply need to –get the parameters for the system call from registers –convert any pointers (ie, char* pointers) from virtual to physical addresses –Pass the parameters to the appropriate UNIX system call (see manpages for open, read and write) –Place the return value in the appropriate register

Converting from virtual to physical addresses Since our user programs use virtual addresses for pointers, if a system call passes a pointer, the kernel must convert the pointer to a physical address (ie, an offset in machine->mainMemory) You cannot use the Translate() call to do this; you have to do it yourself

Converting from virtual to physical addresses Even though you can’t call Translate() yourself, you can translate addresses the same way Translate does, by looking up the virtual page in the pageTable, getting the physical page number, and then adding the offset Look at the code in translate.cc for details

System call support System call support is not necessary for multiprogramming, but you will probably want to get the system call part done first It’s very simple to get working

Project Summary Add the interrupt timer (system.cc) Change progtest.cc so that you create a new thread for each executable (progtest.cc) Create an address space for each executable, and load its code and data into memory, while setting up the page table (addrspace.cc) Add support for Open, Read and Write system calls (exception.cc)

Start Early For individuals, the project is due on April 23rd, at midnight For groups, the project is due on April 18th, at midnight Start now Come to lab sessions, recitations, and office hours