Chapter 3 Memory Management. 3.1 From Programs To Address Space 3 steps to run the programs of an application – A Compiler translates the source code.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Memory Protection: Kernel and User Address Spaces  Background  Address binding  How memory protection is achieved.
Operating Systems1 9. Linking and Sharing 9.1 Single-Copy Sharing –Why Share –Requirements for Sharing –Linking and Sharing 9.2 Sharing in Systems without.
Assembly Code Example Selection Sort.
Program Development Tools The GNU (GNU’s Not Unix) Toolchain The GNU toolchain has played a vital role in the development of the Linux kernel, BSD, and.
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3 J. Levine: Linkers & Loaders
Linking & Loading CS-502 Operating Systems
Operating Systems Lecture Notes Memory Management Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Memory Management Chapter 7.
 Just as processes share the CPU, they also share physical memory. This section is about mechanisms for doing that sharing. EXAMPLE OF MEMORY USAGE Calculation.
Memory Management Questions answered in this lecture: How do processes share memory? What is static relocation? What is dynamic relocation? What is segmentation?
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3.
Modified from Silberschatz, Galvin and Gagne Lecture 16 Chapter 8: Main Memory.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Memory Management 2010.
Modified from Silberschatz, Galvin and Gagne Lecture 15 Chapter 8: Main Memory.
Operating System Concepts
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Software Development and Software Loading in Embedded Systems.
1 User-Level Processes Needed to test the system call you implement The “Noff” format file required –Look at the Makefile in test MIPS “syscall” instruction.
Memory management. Instruction execution cycle Fetch instruction from main memory Decode instruction Fetch operands (if needed0 Execute instruction Store.
Chapter 91 Memory Management Chapter 9   Review of process from source to executable (linking, loading, addressing)   General discussion of memory.
Nachos Instructional OS: Part 2
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
A genda for Today What is memory management Source code to execution Address binding Logical and physical address spaces Dynamic loading, dynamic linking,
CS1550 Assignment 5 Multiprogramming Implementation notes Matt Craven.
Nachos Instructional OS: Part 2
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Topic 2d High-Level languages and Systems Software
Project 2: Initial Implementation Notes Tao Yang.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Nachos Overview 2011 级 OS 课程设计 2013 秋. to get your hands dirty Read and analyze Build observe.
Nachos Project 3.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Nachos Project Assignment 3
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.
Programs and Processes. The Virtual Address Space A typical process VAS space includes: user regions in the lower half V->P mappings specific to each.
Nachos Instructional OS: Part 2
CSC 360, Instructor Kui Wu Memory Management I: Main Memory.
The Assembly Process Computer Organization and Assembly Language: Module 10.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Memory and Addressing It all starts.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Loaders and Linkers T 李俊葦. 1. Loader Accepts the object programs , prepares these programs for execution by the computer , and indicates the execution.
Main Memory CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Lecture 3 Translation.
Memory management.
Chapter 8: Main Memory.
System Programming and administration
Linking & Loading.
Chapter 8 Main Memory.
Program Execution in Linux
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
OPERATING SYSTEMS MEMORY MANAGEMENT
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Memory Management Tasks
Lecture 3: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Loaders and Linkers.
Linking & Loading CS-502 Operating Systems
Virtual Memory Lecture notes from MKP and S. Yalamanchili.
OPERATING SYSTEMS MEMORY MANAGEMENT BY DR.V.R.ELANGOVAN.
Presentation transcript:

Chapter 3 Memory Management

3.1 From Programs To Address Space 3 steps to run the programs of an application – A Compiler translates the source code of each module to its object module, – A linker links all the object modules to form a single binary executable also known as load module, – A loader loads the load module in the memory of the computer

The Linker Each object module has its own sections of text, initialized data, symbol table and relocation information The task of the linker is to merge all the object modules into one load module This requires relocating the object modules

Loader Logical address spaces – The starting address of this space is 0 This logical address to a physical address – CPU and OS

3.2 Memory Management Schemes Contiguous Allocation Paging Segmentation Segmentation with Paging

3.3 Swapping 略

3.4 MIPS Simulator Components of MIPS Machine

The major components of the machine – user registers: int registers[NumTotalRegs]; – main memory: char *mainMemory; – page table for the current user process: TranslationEntry *pageTable; – tlb (table look-ahead buffer): TranslationEntry *tlb;

The machine operations 129 bool ReadMem(int addr, int size, int* value); 130 bool WriteMem(int addr, int size, int value); 116 int ReadRegister(int num); // read a register 118 void WriteRegister(int num, int value); 114 void Run(); // Run a user program void OneInstruction(Instruction *instr); 142 void RaiseException(ExceptionType which, int badVAddr); 135 ExceptionType Translate(int virtAddr, int* physAddr, int size,bool writing);

3.4.2 Instruction Interpretation OneInstruction(Instruction*) see P46

3.5 Nachos User Programs Use gcc MIPS cross compiler to produce the executable in the normal UNIXCOFF format Use program coff2noff made in directory../bin/ to convert it to the Nachos NOFF format – NOFF format is the format of binary executables used by Nachos. – It is similar to COFF format – See p48

NOFF format #define NOFFMAGIC 0xbadfad typedef struct segment { – int virtualAddr; /* location of segment in virt addr space */ – int inFileAddr; /* location of segment in this file */ – int size; /* size of segment */ 16 } } Segment ; typedef struct noffHeader { – int noffMagic; /* should be NOFFMAGIC */ – Segment code; /* executable code segment */ – Segment initData; /* initialized data segment */ – Segment uninitData; /* uninitialized data segment */ } NoffHeader;

3.6 Address Space of User Process in Nachos Nachos uses paging An address space is formed by calling the constructor of AddrSpace Nachos uses the a stub file system built on top of the UNIX system, see p51. Create address space – Page the table – Code – InitData

3.7 Memory Management in Nachos Address translation see p54 both page table and TLB the alignment of the logical address is checked The page number and the offset of the logical address are calculated The TLB can translation generates a pagefault Physical address is also checked

3.8 From Thread to User Process After the thread constructs the address space and initializes the registers, it becomes a user process running on the simulated MIPS machine by calling machine->Run() If both the Nachos kernel and the user program were running on a real MIPS raw machine, a kernel thread becomes the user process by jumping to the first instruction of the code section of the address space