CS 450 Module R4. R4 Overview Due on March 11 th along with R3. R4 is a small yet critical part of the MPX system. In this module, you will add the functionality.

Slides:



Advertisements
Similar presentations
Linux device-driver issues
Advertisements

Process Management.
Dynamic Allocation and Linked Lists. Dynamic memory allocation in C C uses the functions malloc() and free() to implement dynamic allocation. malloc is.
Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
Project: Processes and Resource Management Textbook: pages Lubomir Bic.
CS 450 Module R3. Next Week R2 is due next Friday ▫Make sure to correct all errors with R1 ▫Correct errors in the documentation as well, it will be checked.
CS 450 Module R1. R1 Introduction In Module R1, you will implement a user interface (command handler). There are a couple of options: ▫Command Line: interface.
Module R2 Overview. Process queues As processes enter the system and transition from state to state, they are stored queues. There may be many different.
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.
CS 450 MPX P ROJECT Introduction to MPX. I NTRODUCTION TO MPX The MPX module is divided into six modules Module R1: User Interface Module R2: Process.
CS1061: C Programming Lecture 21: Dynamic Memory Allocation and Variations on struct A. O’Riordan, 2004, 2007 updated.
Tips for R3: Process Initialization When we create processes to represent our 5 test procedures we must correctly initialize its context by placing values.
Informática II Prof. Dr. Gustavo Patiño MJ
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.
Process Description and Control Module 1.0. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
Processes CSCI 444/544 Operating Systems Fall 2008.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
Pointers Applications
1 Procedural Concept The main program coordinates calls to procedures and hands over appropriate data as parameters.
Week 9 Part 2 Kyle Dewey. Overview Announcement More with structs and memory Assertions Exam #2 Course review.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
CS 450 Module R6. Next Week R5 is due next Friday (April 3) No documentation, no source code due R5 is stand-alone, so I will not be checking errors from.
CS 450 Module R6. Next Week R5 is due Friday after Break ( April 1st ) ▫No documentation, no source code due ▫R5 is stand-alone, so I will not be checking.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Introduction to Processes CS Intoduction to Operating Systems.
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Chapter 4 Processes. Process: what is it? A program in execution A program in execution usually usually Can also have suspended or waiting processes Can.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 12: Pointers continued, C strings.
1 C - Memory Simple Types Arrays Pointers Pointer to Pointer Multi-dimensional Arrays Dynamic Memory Allocation.
Stack and Heap Memory Stack resident variables include:
Copyright © 2005 Elsevier Chapter 8 :: Subroutines and Control Abstraction Programming Language Pragmatics Michael L. Scott.
C++ Programming: From Problem Analysis to Program Design, Second Edition1 Objectives In this chapter you will: Learn about the pointer data type and pointer.
Device Drivers CPU I/O Interface Device Driver DEVICECONTROL OPERATIONSDATA TRANSFER OPERATIONS Disk Seek to Sector, Track, Cyl. Seek Home Position.
1 C++ Classes and Data Structures Jeffrey S. Childs Chapter 4 Pointers and Dynamic Arrays Jeffrey S. Childs Clarion University of PA © 2008, Prentice Hall.
Dynamic Memory Allocation. Domain A subset of the total domain name space. A domain represents a level of the hierarchy in the Domain Name Space, and.
CS 450 Module R3. Today's Agenda R1 and R2 review Module R3 Introduction Schedule R1 Grading Next Week Module R4 Introduction.
Chapter 12: String Manipulation Introduction to Programming with C++ Fourth Edition.
Copyright 2005, The Ohio State University 1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation.
QA and Testing. QA Activity Processes monitoring Standards compliance monitoring Software testing Infrastructure testing Documentation testing Usability.
Module R3 Process Scheduling. Module R3 involves the creation of a simple “Round Robin” dispatcher. The successful completion of this module will require.
Generic lists Vassilis Athitsos. Problems With Textbook Interface? Suppose that we fix the first problem, and we can have multiple stacks. Can we have.
12/23/2015Engineering Problem Solving with C++, second edition, J. Ingber 1 Engineering Problem Solving with C++, Etter/Ingber Chapter 9 An Introduction.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Pointers.
Processes and Virtual Memory
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
Pointers1 WHAT IS A POINTER? Simply stated, a pointer is an address. A running program consists of three parts: execution stack, code, and data. They are.
Processes 2 Introduction to Operating Systems: Module 4.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 11: Pointers.
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.
C Programming Day 2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Union –mechanism to create user defined data types.
Process concept.
5.13 Recursion Recursive functions Functions that call themselves
Unix Process Management
ENEE150 Discussion 13 Section 0101 Adam Wang.
Structure of Processes
Dynamic Memory Allocation
System Structure and Process Model
Pointers, Dynamic Data, and Reference Types
Dynamic Memory Allocation
Process Description and Control
Review & Lab assignments
EENG212 – Algorithms & Data Structures Fall 07/08 – Lecture Notes # 5b
Homework Continue with K&R Chapter 5 Skipping sections for now
Processes in Unix and Windows
Implementation of page-replacement algorithms and Belady’s anomaly
Structure of Processes
Presentation transcript:

CS 450 Module R4

R4 Overview Due on March 11 th along with R3. R4 is a small yet critical part of the MPX system. In this module, you will add the functionality to dynamically load MPX programs into the system. We will load programs from files. The filename will also be the process name. Functions ▫Load Program- load a single MPX process Permanent Commands ▫Load- allows the user to load an MPX program ▫Terminate- allows the user to terminate a program

Load Program Function Parameters: ▫char[]: filename  The support functions we will use assume the.MPX extension, so this will not be part of the filename. For example, if we want to load “Proc1.mpx”, the parameter sent to this function would be “Proc1” ▫int: priority Returns: void Loads a single MPX process: ▫Allocates and sets up a new PCB ▫Allocates program memory ▫Loads a program into the allocated memory ▫Place new process in the queue

Load Program Check the arguments ▫Check that the priority is valid ▫Check that the process name is unique Check the program ▫There is a support software function (sys_check_program) that checks that a program exists and is valid. More discussion on this later. Create and setup the PCB ▫You should call your setup_pcb function ▫Process name should be the filename, the priority is passed as an argument to the load program function, and the class should be set to “Application” ▫Put the process in the ready, suspended state Allocate the program’s memory (Set PCB values) ▫The memory size, load address, and execution address must be set. You will get the load address from sys_alloc_mem. The rest will come from the sys_check_program function. ▫You will also need to manually set some of the registers for the process: IP, CS, DS, ES and FLAGS Load the program ▫There is a support software function (sys_load_program) that loads the program ▫If loaded without error, insert the PCB into the appropriate queue (ready or ready-suspended)

Sys_check_program int sys_check_program(char dir_name[], char prog_name[], int* prog_len_p, int* start_offset_p); Returns int ▫0: program is valid ▫ERR_SUP_NAMLNG: pathname too long ▫ERR_SUP_FILNFD: file not found ▫ERR_SUP_FILINV: file is not valid Parameters ▫char[] dir_name  directory for the specified file. May use or “\0” with quotes to always search only the current directory- DO NOT USE “NULL”- it will not work! ▫char[] prog_name  Filename for the program to be checked. Assumed to have a.MPX extension ▫int* prog_len_p  Sys_check_program will put the program length, in bytes, into this integer variable. This is the exact number of bytes which has to be allocated for this program. ▫int* start_offset_p  Sys_check_program will put the offset in bytes from the start of the load area at which execution should begin

Setting PCB Memory Values memory_size ▫This should be set to the value returned by sys_check_program (the third parameter) load_address ▫You will need to use sys_alloc_mem to allocate a memory block, with size memory_size. You should set the PCB’s load_address to the return value from sys_alloc_mem. Make sure you cast it to unsigned char*  load_address = (unsigned char*)sys_alloc_mem(-PCB’s memory size-) execution_address ▫Set this equal to the load_address + start_offset_p  Start_offset_p is the fourth param in the sys_check_program call Registers ▫You first need to create a context pointer to the PCB’s stack top- make sure you do this AFTER you have setup the PCB.  context cp* = (context *) pcb->stack_top ▫Set the IP & CS  IP = FP_OFF(execution_address)  CS = FP_SEG(execution_address) ▫Set the DS and ES to _DS, _ES ▫Set flags to 0x200

Sys_load_program int sys_check_program(void *load_addr, int max_size, char dir_name[], char prog_name[]); Returns int ▫0 if OK ▫Check manual for errors Parameters ▫void* load_addr  Starting address of the memory region into which the program should be loaded. This is what is returned by sys_alloc_mem, and should be what you set the load_address of the PCB to. ▫int max_size  Size of the available memory. You will pass the PCB memory_size. ▫dir_name, prog_name  Same as sys_check_program

Load command We need a command to load processes This should take in the program name as a parameter, optionally could take the priority as a parameter ▫If the priority is omitted, use a priority of zero ▫Program name should not include the extension Suggested command name: load This will be a permanent command, and replaces the Create PCB command (you may wish to leave the Create PCB command in for now though) Display any appropriate error messages

Terminate Terminates a process by removing it from queues, deallocating its PCB and releasing its memory ▫Will need to modify your free_pcb function to free all memory allocated using sys_alloc_mem, including:  Load address  Stack base  The PCB itself Should take the process name as argument Replaces the Delete PCB command Display any appropriate error messages Should not allow a “SYSTEM” class process to be terminated. This will not be tested with R4 but will be critical in Module R6.

Test MPX Programs Located on Dr. Mooney’s Website under MPX Support Software Download all of the test processes for assignment 4 (download the.MPX files, not the.ASM files). Try loading them into your system, then resume them and call dispatcher to see how they execute.

Tips In your free-pcb function (from R2), make sure that you are freeing the the memory from the following addresses using sys_free_mem: ▫stack_base ▫load_address ▫The pcb itself In the sys_check_program and sys_load_program functions, do not use “NULL”, use “’\0’” instead.

Documentation No documentation due, but you should update all existing manuals with any added functions/commands.