CS703 - Advanced Operating Systems

Slides:



Advertisements
Similar presentations
4/14/2017 Discussed Earlier segmentation - the process address space is divided into logical pieces called segments. The following are the example of types.
Advertisements

CS 153 Design of Operating Systems Spring 2015
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Memory Management (II)
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
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.
Chapter 3.2 : Virtual Memory
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
CS333 Intro to Operating Systems Jonathan Walpole.
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
Lecture 19: Virtual Memory
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Virtual Memory Additional Slides Slide Source: Topics Address translation Accelerating translation with TLBs class12.ppt.
CHAPTER 3-3: PAGE MAPPING MEMORY MANAGEMENT. VIRTUAL MEMORY Key Idea Disassociate addresses referenced in a running process from addresses available in.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
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”
Week 5:Virtual Memory CS 162. Today’s Section Administrivia Quiz Review of Lecture Worksheet and Discussion.
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.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 33 Paging Read Ch. 9.4.
CS161 – Design and Architecture of Computer
Memory Management Virtual Memory.
CS161 – Design and Architecture of Computer
CSE 120 Principles of Operating
CSE 451: Operating Systems Winter 2007 Module 10 Memory Management
Lecture 12 Virtual Memory.
CS703 - Advanced Operating Systems
COMBINED PAGING AND SEGMENTATION
CSE451 Operating Systems Winter 2011
CSE 451: Operating Systems Winter 2010 Module 10 Memory Management
CS 704 Advanced Computer Architecture
Chapter 8: Main Memory Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
CSE 451: Operating Systems Winter 2014 Module 11 Memory Management
Chapter 8: Main Memory.
Virtual Memory Partially Adapted from:
Operating System Concepts
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
CS 105 “Tour of the Black Holes of Computing!”
Main Memory Background Swapping Contiguous Allocation Paging
Lecture 3: Main Memory.
CSE451 Memory Management Introduction Autumn 2002
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
Operating System Chapter 7. Memory Management
Virtual Memory Overcoming main memory size limitation
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Winter 2004 Module 10.5 Segmentation
CSE 451: Operating Systems Winter 2007 Module 10 Memory Management
CSE451 Virtual Memory Paging Autumn 2002
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 2009 Module 10 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management CSE451 Andrew Whitaker.
CS 105 “Tour of the Black Holes of Computing!”
Paging and Segmentation
CSE 451: Operating Systems Lecture 10 Paging & TLBs
CSE451 Operating Systems Winter 2009
Chapter 8: Main Memory CSS503 Systems Programming
Sarah Diesburg Operating Systems CS 3430
CSE 451: Operating Systems Autumn 2010 Module 10 Memory Management
CSE 542: Operating Systems
Sarah Diesburg Operating Systems COP 4610
Virtual Memory 1 1.
Page Main Memory.
Presentation transcript:

CS703 - Advanced Operating Systems By Mr. Farhan Zaidi

Lecture No. 25

Overview of today’s lecture Segmentation Combined Segmentation and paging Efficient translations and caching Translation Lookaside Buffer (TLB)

Segmentation Paging mitigates various memory allocation complexities (e.g., fragmentation) view an address space as a linear array of bytes divide it into pages of equal size (e.g., 4KB) use a page table to map virtual pages to physical page frames page (logical) => page frame (physical) Segmentation partition an address space into logical units stack, code, heap, subroutines, … a virtual address is <segment #, offset>

What’s the point? More “logical” absent segmentation, a linker takes a bunch of independent modules that call each other and organizes them they are really independent; segmentation treats them as such Facilitates sharing and reuse a segment is a natural unit of sharing – a subroutine or function A natural extension of variable-sized partitions variable-sized partition = 1 segment/process segmentation = many segments/process

Hardware support Segment table multiple base/limit pairs, one per segment segments named by segment #, used as index into table a virtual address is <segment #, offset> offset of virtual address added to base address of segment to yield physical address

Segment lookups <? + segment 0 segment 1 segment 2 yes segment 3 no segment table base limit physical memory segment 0 segment # offset segment 1 virtual address segment 2 yes <? + segment 3 no segment 4 raise protection fault

Segmentation pros & cons + efficient for sparse address spaces + easy to share whole segments (for example, code segment) Need to add protection mode in segmentation table. For example, code segment would be read-only (only execution and loads are allowed). Data and stack segment would be read-write (stores allowed). - complex memory allocation - Still need first fit, best fit, etc., and re-shuffling to coalesce free fragments, if no single free space is big enough for a new segment.

Linux: 1 kernel code segment, 1 kernel data segment 1 user code segment, 1 user data segment N task state segments (stores registers on context switch) 1 “local descriptor table” segment (not really used) all of these segments are paged

Segmentation with paging translation

Segmentation with paging translation Pros & Cons + only need to allocate as many page table entries as we need. In other words, sparse address spaces are easy. + easy memory allocation + share at seg or page level - pointer per page (typically 4KB - 16KB pages today) - page tables need to be contiguous - two lookups per memory reference

Integrating VM and Cache CPU Trans- lation Cache Main Memory VA PA miss hit data Most Caches “Physically Addressed” Accessed by physical addresses Allows multiple processes to have blocks in cache at same time Allows multiple processes to share pages Cache doesn’t need to be concerned with protection issues Access rights checked as part of address translation Perform Address Translation Before Cache Lookup But this could involve a memory access itself (of the PTE) Of course, page table entries can also become cached

Caching review Cache: copy that can be accessed more quickly than original. Idea is: make frequent case efficient, infrequent path doesn't matter as much. Caching is a fundamental concept used in lots of places in computer systems. It underlies many of the techniques that are used today to make computers go fast: can cache translations, memory locations, pages, file blocks, file names, network routes, authorizations for security systems, etc. Generic Issues in Caching Cache hit: item is in the cache Cache miss: item is not in the cache, have to do full operation Effective access time = P (hit) * cost of hit + P (miss) * cost of miss 1. How do you find whether item is in the cache (whether there is a cache hit)? 2. If it is not in cache (cache miss), how do you choose what to replace from cache to make room? 3. Consistency -- how do you keep cache copy consistent with real version?

Speeding up Translation with a TLB “Translation Lookaside Buffer” (TLB) Small hardware cache in MMU Maps virtual page numbers to physical page numbers Contains complete page table entries for small number of pages CPU TLB Lookup Cache Main Memory VA PA miss hit data Trans- lation

Translation Buffer, Translation Lookaside Buffer Hardware table of frequently used translations, to avoid having to go through page table lookup in common case. Typically, on chip, so access time of 2-5ns, instead of 30-100ns for main memory. How do we tell if needed translation is in TLB? 1. Search table in sequential order 2. Direct mapped: restrict each virtual page to use specific slot in TLB For example, use upper bits of virtual page number to index TLB. Compare against lower bits of virtual page number to check for match.

What if two pages conflict for the same TLB slot? Ex: program counter and stack. One approach: pick hash function to minimize conflicts What if use low order bits as index into TLB? What if use high order bits as index into TLB? Thus, use selection of high order and low order bits as index. 3. Set associativity: arrange TLB (or cache) as N separate banks. Do simultaneous lookup in each bank. In this case, called "N-way set associative cache". More set associativity, less chance of thrashing. Translations can be stored, replaced in either bank. 4. Fully associative: translation can be stored anywhere in TLB, so check all entries in the TLB in parallel.

Direct mapped TLB