ECE 598 Advanced Operating Systems Lecture 10

Similar documents
ECE 598 Advanced Operating Systems Lecture 12

Preview. Memory Management

Memory Management. Today. Next Time. Basic memory management Swapping Kernel memory allocation. Virtual memory

Memory Management. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

Memory Management. COMP755 Advanced Operating Systems

Requirements, Partitioning, paging, and segmentation

Memory Management william stallings, maurizio pizzonia - sistemi operativi

Memory Management. To do. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

Requirements, Partitioning, paging, and segmentation

CS61C : Machine Structures

Memory Management Basics

CS399 New Beginnings. Jonathan Walpole

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Memory management. Johan Montelius KTH

Heap Management portion of the store lives indefinitely until the program explicitly deletes it C++ and Java new Such objects are stored on a heap

Memory Allocation. Static Allocation. Dynamic Allocation. Dynamic Storage Allocation. CS 414: Operating Systems Spring 2008

Memory management: outline

Memory management: outline

Memory Management. CSE 2431: Introduction to Operating Systems Reading: , [OSC]

Memory Management. Memory Management

A.Arpaci-Dusseau. Mapping from logical address space to physical address space. CS 537:Operating Systems lecture12.fm.2

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems 3rd edition Uses content with permission from Assoc. Prof. Florin Fortis, PhD

Operating Systems and Computer Networks. Memory Management. Dr.-Ing. Pascal A. Klein

Process. Memory Management

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Memory management. Knut Omang Ifi/Oracle 10 Oct, 2012

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 358

CIS Operating Systems Memory Management. Professor Qiang Zeng Fall 2017

Classifying Information Stored in Memory! Memory Management in a Uniprogrammed System! Segments of a Process! Processing a User Program!

Physical memory vs. Logical memory Process address space Addresses assignment to processes Operating system tasks Hardware support CONCEPTS 3.

Process. One or more threads of execution Resources required for execution

16 Sharing Main Memory Segmentation and Paging

ECE 598 Advanced Operating Systems Lecture 10

Goals of Memory Management

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Memory Management. Dr. Yingwu Zhu

Memory Management. Goals of Memory Management. Mechanism. Policies

Dynamic Memory Allocation

15 Sharing Main Memory Segmentation and Paging

CS61C : Machine Structures

Operating Systems. 09. Memory Management Part 1. Paul Krzyzanowski. Rutgers University. Spring 2015

CS Operating Systems

CS Operating Systems

MEMORY MANAGEMENT. Jo, Heeseung

! What is main memory? ! What is static and dynamic allocation? ! What is segmentation? Maria Hybinette, UGA. High Address (0x7fffffff) !

ECE 598 Advanced Operating Systems Lecture 14

In multiprogramming systems, processes share a common store. Processes need space for:

Background. Contiguous Memory Allocation

Engine Support System. asyrani.com

Chapter 3 - Memory Management

Dynamic Memory Allocation. Zhaoguo Wang

CIS Operating Systems Non-contiguous Memory Allocation. Professor Qiang Zeng Spring 2018

Outlook. File-System Interface Allocation-Methods Free Space Management

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

Memory Management. Memory Management Requirements

Dynamic Memory Management! Goals of this Lecture!

12: Memory Management

Chapter 7 Memory Management

Memory: Overview. CS439: Principles of Computer Systems February 26, 2018

Segmentation. Multiple Segments. Lecture Notes Week 6

Optimizing Dynamic Memory Management

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

Lecture 7. Memory Management

ECE 598 Advanced Operating Systems Lecture 22

CIS Operating Systems Contiguous Memory Allocation. Professor Qiang Zeng Spring 2018

Run-time Environments - 3

Performance of Various Levels of Storage. Movement between levels of storage hierarchy can be explicit or implicit

CS61C : Machine Structures

ECE 571 Advanced Microprocessor-Based Design Lecture 12

CS61C : Machine Structures

Memory management OS

Operating Systems Memory Management. Mathieu Delalandre University of Tours, Tours city, France

Introduction to Operating Systems

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

Memory Management (Chaper 4, Tanenbaum)

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

ECE 471 Embedded Systems Lecture 5

Princeton University. Computer Science 217: Introduction to Programming Systems. Dynamic Memory Management

COMPUTER SCIENCE 4500 OPERATING SYSTEMS

The Memory Management Unit. Operating Systems. Autumn CS4023

Administrivia. Deadlock Prevention Techniques. Handling Deadlock. Deadlock Avoidance

Chapter 8 Main Memory

Lecture 7 More Memory Management Slab Allocator. Slab Allocator

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Run-time Environments -Part 3

memory management Vaibhav Bajpai

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure.

Memory Management. Jo, Heeseung

Objectives and Functions Convenience. William Stallings Computer Organization and Architecture 7 th Edition. Efficiency

ECE 471 Embedded Systems Lecture 4

Memory Management. Frédéric Haziza Spring Department of Computer Systems Uppsala University

CSCI-UA /2. Computer Systems Organization Lecture 19: Dynamic Memory Allocation: Basics

3. Memory Management

ECE 471 Embedded Systems Lecture 6

Operating System Support

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Memory Management. Contents: Memory Management. How to generate code? Background

Motivation for Dynamic Memory. Dynamic Memory Allocation. Stack Organization. Stack Discussion. Questions answered in this lecture:

CS307: Operating Systems

Transcription:

ECE 598 Advanced Operating Systems Lecture 10 Vince Weaver http://www.eece.maine.edu/~vweaver vincent.weaver@maine.edu 17 February 2015

Announcements Homework #1 and #2 grades, HW#3 Coming soon 1

Various Types of Memory Management Application Operating System Hardware 2

Application Memory Allocation on Linux compiler can (and will) optimize away memory accesses when possible and optimization enabled. As long as you don t use a pointer to the variable (the register keyword makes this explicit). Local variables on the stack Stack auto-grows down Global and static variables that are initialized in the data segment, loaded directly from disk. 3

Global and static variables initialized to zero in the bss segment. Dynamic variables allocated on the heap or via mmap malloc() is not a syscall, but a library call. Kernel interface is the brk() system call which moves the end of the data segment (essentially making the heap bigger) mmap() initially was map file into memory so can be accessed with memory allocations rather than read/write 4

anonymous mmap will allocate memory range with no backing file. 5

How Heap/Malloc Works Memory allocation libraries can vary underneath. Basically a big chunk of RAM is grabbed from the OS, and then split into parts in a custom way. The biggest problem is fragmentation, which happens when memory is freed in non-contiguous areas. dlmalloc Doug Lea glibc uses ptmalloc based on it. Memory allocated in chunks, with 8 or 16-byte header bins of same sized objects, doubly linked list 6

Small allocations (256kB?) closest power of two used Larger, mmap used, multiple of page size. 7

Manual vs Automatic With C you can manually allocate and free memory. Prone to errors: Use-after-free errors Buffer overflows Memory Leaks High-level languages such as Java will automatically allocate memory for objects. The user never sees memory pointers. Unused memory areas are periodically freed via 8

garbage-collection. At the same time the memory can be compacted, avoiding fragmentation. Problem? Slow, not real-time, can be complex detangling complex memory dependency chains. 9

Memory Allocation on uclinux sbrk() doesnt work mmap overhead 10

Operating System Setup 11

Mono-Programming Simple mono-programming: just OS and one program in memory at once (like DOS) 12

Fixed Multi-Programming Multiprogramming: let you run multiple tasks at once. Fixed Partitions of memory available. Jobs queued. When spot frees up job can run. Can have complex scheduling rules out which size and priority to give to jobs. Older mainframes (OS/MFT) used this. Relocations a problem Memory protection. Permissions on pages. 13

Solution to both protection and permission in segments (with base offset and range that are valid to access) 14

Swapping Timesharing systems. All jobs not fit in RAM? Swapping: bring in each program in entirety, run it a while, then when done writing all back out to disk. Paging: virtual memory. 15

Fragmentation Enough memory available, but split up. How can fix? Memory compaction. Swap everything out, bring it back in (Relocating) 16

Tracking Memory What granularity should be used? Bitmap chunks of memory, a bitmap representing it all. Have to search bitmap and find N consecutive empty areas for each allocation Free-lists, linked list of memory areas 17

Fit Algorithms Scans memory, returns first block big enough to meet request. Fastest. Next fit. Picks up where the last first fit case left off (optimization) Best fit search entire map and find hole that fits it best. Actually causes more fragmentation, end up with lots of tiny holes Worst Fit always biggest hole. Not so great either. 18

Quick Fit separate lists for more common sizes 19

Fixed Sized Allocation Memory Pool fast blocks of pre-allocated memory in power of two sizes that can be handed out fast to allocate/free fragmentation 20

Buddy Allocator Used by Linux Pre-allocated areas of various sizes Separate free lists for each area Rounds up request and tries to get for that size If none available, try next one up. 21