Memory Management References text: Tanenbaum ch.4.

Slides:



Advertisements
Similar presentations
16.317: Microprocessor System Design I
Advertisements

Configuring the Operating System Configure Performance Options Processor scheduling and memory usage Virtual memory Memory for network performance Configure.
CS 153 Design of Operating Systems Spring 2015
Memory Management Design & Implementation Segmentation Chapter 4.
Memory Management (II)
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management -3 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
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 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
1 Memory Management Virtual Memory Chapter 4. 2 The virtual memory concept In a multiprogramming environment, an entire process does not have to take.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
CSE378 Virtual memory.1 Evolution in memory management techniques In early days, single program ran on the whole machine –used all the memory available.
1 Memory Management Chapter Basic memory management 4.2 Swapping (εναλλαγή) 4.3 Virtual memory (εικονική/ιδεατή μνήμη) 4.4 Page replacement algorithms.
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.
1 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
Chapter 4 Memory Management Virtual Memory.
Fundamentals of Programming Languages-II Subject Code: Teaching SchemeExamination Scheme Theory: 1 Hr./WeekOnline Examination: 50 Marks Practical:
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
Review °Apply Principle of Locality Recursively °Manage memory to disk? Treat as cache Included protection as bonus, now critical Use Page Table of mappings.
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
X86 (32-bit) Paging Reference –text: Tanenbaum ch.4.3 Reference on Win2K memory management –text: Tanenbaum ch
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
SLC/VER1.0/OS CONCEPTS/OCT'99
Memory Management Virtual Memory.
Memory Management.
Memory Management (2).
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
Lecture 12 Virtual Memory.
Memory Caches & TLB Virtual Memory
CS703 - Advanced Operating Systems
Memory Management References text: Tanenbaum ch.4.
Module 9: Virtual Memory
Chapter 8: Main Memory.
Lecture 28: Virtual Memory-Address Translation
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Module IV Memory Organization.
5: Virtual Memory Background Demand Paging
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
Operating Systems.
Lecture 3: Main Memory.
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
Contents Memory types & memory hierarchy Virtual memory (VM)
Chapter 8: Memory Management strategies
Lecture 37 Syed Mansoor Sarwar
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Evolution in memory management techniques
Evolution in memory management techniques
Evolution in memory management techniques
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Module 9: Virtual Memory
Virtual Memory.
4.3 Virtual Memory.
CSE 542: Operating Systems
Virtual Memory 1 1.
Page Main Memory.
Presentation transcript:

Memory Management References text: Tanenbaum ch.4

Memory Management Functions protect multiple programs from interfering with one another (e.g. user vs. kernel mode execution) manage the address space of the processes (e.g.virtual memory)

User and Kernel Modes All CPUs used for serious OS’s have at least 2 modes of execution (privilege levels or rings) 4 privilege levels for x86 processors 0: system level (used by UNIX/Linux/Win2k kernels) 1: unused 2: unused 3: user level (used by UNIX/Linux/Win2k user programs) Store current privilege level in the CS(code segment) register

User-Kernel Mode Transitions Via system calls use a system call number and the arguments user code executes a single instruction Via interrupts use the CPU trap cycle; turn off interrupts; get a device identifier user code may not be aware of interrupts

Memory Management Approaches Without swapping or paging Monoprogramming OS with one user process Multiprogramming with fixed partitions multiple processes run at once fix partition size at system start up Swapping Virtual memory

Monoprogramming Only 1 process can run at a time

Multiprogramming w/Fixed number of Tasks (MFT) Fixed memory partitions separate input queues single input queue

CPU Utilization Degree of multiprogramming (# of processes in memory)

Swapping Studied this during the scheduling lecture memory scheduler decides which process stays in memory and which process stores on disk can run into overload if it tries to fit too many processes in memory

Virtual Memory Useful when the combined size of the program, stack, data exceeds the available physical memory Memory Management Unit(MMU) maps virtual addresses to physical addresses Page table

Paging Pages Page Frames Page Tables virtual address space divided into pages typical 4K byte size (e.g. 64K program in 16 pages) program extends over 1 page will take the entire additional page Page Frames physical address space divided into page frames same size as pages (e.g. 32K memory in 8 page frames) Page Tables tells which page frame is assigned to each page of the virtual address(VA)

Virtual and Physical Addresses The relation between virtual addresses and physical memory addresses given by page table A 64KB memory (16 bits) example: page 0 -> page frame 2 page 1 -> page frame 1 page 2 -> page frame 6 page 6 -> nothing(V bit=0)

Internal Operations of MMU Specify 16-bit address and a 4-KB page size using 4 bits for virtual pages and 12 bits for offset present bit also called valid bit(v bit) in x86

Paging Examples mov REG, 8192 Virtual addr =8192 =0x2000; start of page 2; -> page frame 6; Physical addr 24K- 28K; offset =0; Physical addr = 0x6000 mov REG, 8196 Virtual addr =8196 =0x2004; in page 2 -> page frame 6; Physical addr=24K- 28K; offset =4; Physical addr = 0x6004

Multilevel Page Tables 32-bit address space has 1 million 4KB pages Get around having to store huge page tables in memory all the time

Multilevel Paging Example 4M chunk 4K chunk 0x0040 3004 corresponds to PT1 =0x01, PT2=0x03, offset =0x04 MMU uses PT1 to index into the top level table and PT1=1 corresponds to addresses 4M-8M MMU uses PT2 to index into the second level table and PT2=3 points to 3x4096 to 4x4096-1 within the 4M chunk If page is not in memory, Present/absent bit =0 and accessing the page causes a page fault If page is in memory, present/absent bit =1 and the second page memory and offset forms the physical address

Typical Page Table Entry Highly machine dependent.Typically 32-bit wide Protection bit control access(r/w, or r only) Modified(dirty) and referenced bits modified bit controls writing back to disk referenced bit indicates whether the page has been written/read or not. OS uses it to evict a page when a page fault occurs. Caching disabled bit control caching of I/O ports mapped to memory

Page Directory Entry(PDE) x86 Paging 10 bits 10 bits 12 bits 32-bit virtual address Page Table Directory Pointer to page table 20 bits: page addr 12 bits: ref page access and caching flags Pointer to page table 20 bits: page addr 12 bits: ref page access and caching flags Pointer to page table 20 bits: page addr 12 bits: ref page access and caching flags Page Directory Entry(PDE) 20 bits: page table number 12 bits: ref page access and caching flags 1 1023 Page Table Page table number n Page table entry 20 bits: page address 12 bits: ref page access and caching flags Page Table Entry(PTE) 20 bits: physical address 12 bits: cache control, page access protect 1 1023 Page m 32-bit physical address 20 bits 12 bits

x86 Paging (cont’d) A Page Table Directory (PD) has 1024 Page Directory Entries(PDE) which point to 1024 page tables each entry has 32 bits Each Page Table(PT) has 1024 Page Table Entries(PTE) which point to 1024 pages Each page has 4096 memory locations Total address 1024x1024x4096= 4G