CS 390 Chapter 8 Homework Solutions

Similar documents
Main Memory CHAPTER. Exercises. 7.9 Explain the difference between internal and external fragmentation. Answer:

CS 550 Operating Systems Spring Memory Management: Paging

390 Chapter 8 Main Memory

CS399 New Beginnings. Jonathan Walpole

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

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

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

CS307: Operating Systems

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

Chapter 8: Memory Management

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

Chapter 8 Memory Management

CS3600 SYSTEMS AND NETWORKS

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

memory management Vaibhav Bajpai

Page Tables. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University


Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Chapter 8: Memory-Management Strategies

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Memory Management. Dr. Yingwu Zhu

Chapter 8 Main Memory

Preview. COSC350 System Software, Fall

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies

Processes, Address Spaces, and Memory Management. CS449 Spring 2016

ANSWERS OF SELECTED EXERCISES Memory Management Strategies

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

Main Memory: Address Translation

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Main Memory

UNIT-III VIRTUAL MEMORY

Chapter 8: Main Memory

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

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition

CS307 Operating Systems Main Memory

File System. Preview. File Name. File Structure. File Types. File Structure. Three essential requirements for long term information storage

CS370 Operating Systems

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

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

Virtual Memory. Kevin Webb Swarthmore College March 8, 2018

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Memory Management. CSCI 315 Operating Systems Design Department of Computer Science

Virtual Memory 1. To do. q Segmentation q Paging q A hybrid system

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

Chapter 12: File System Implementation

Memory Management. Memory Management

Outlook. Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium

CSCI 4500 / 8506 Sample Questions for Quiz 5

Basic Memory Management

Principles of Operating Systems

Memory Management. Goals of Memory Management. Mechanism. Policies

Memory Management. 3. What two registers can be used to provide a simple form of memory protection? Base register Limit Register

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems

CS 31: Intro to Systems Virtual Memory. Kevin Webb Swarthmore College November 15, 2018

Memory Management. Memory Management

15 Sharing Main Memory Segmentation and Paging

CS 3733 Operating Systems:

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University

Background. Contiguous Memory Allocation

CS370 Operating Systems

EECS 482 Introduction to Operating Systems

Paging, and segmentation

16 Sharing Main Memory Segmentation and Paging

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck

Virtual Memory. 11/8/16 (election day) Vote!

Virtualizing Memory: Paging. Announcements

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

CS 134: Operating Systems

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

File Directories Associated with any file management system and collection of files is a file directories The directory contains information about

Chapter 8: Memory- Manage g me m nt n S tra r t a e t gie i s

CSE 4/521 Introduction to Operating Systems. Lecture 14 Main Memory III (Paging, Structure of Page Table) Summer 2018

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

6. Which of the following operating systems was the predecessor of Microsoft MS-DOS? a. Dynix b. Minix c. CP/M

Operating Systems, Fall

Operating Systems, Fall

CS420: Operating Systems. Paging and Page Tables

Chapter 3: Important Concepts (3/29/2015)

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

Paging & Segmentation

ECE 598 Advanced Operating Systems Lecture 10

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

CS 261 Fall Mike Lam, Professor. Virtual Memory

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

Virtual Memory. Today. Segmentation Paging A good, if common example

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1

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

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

SHANDONG UNIVERSITY 1

Chapter 8. Virtual Memory

CIS Operating Systems Memory Management Address Translation for Paging. Professor Qiang Zeng Spring 2018

Operating Systems. Paging... Memory Management 2 Overview. Lecture 6 Memory management 2. Paging (contd.)

Requirements, Partitioning, paging, and segmentation

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

Transcription:

CS 390 Chapter 8 Homework Solutions 8.3 Why are page sizes always... Page sizes that are a power of two make it computationally fast for the kernel to determine the page number and offset of a logical address. The page number can be determined by right-shifting the logical address. The offset can be determined by masking out some number of the most-significant bits of the logical address. 8.4 Consider a logical address space... a. We need to calculate the total number logical addresses: There are 2 6 pages 2 10 words per page = 2 16 words in the logical address space. Thus, logical addresses need to be at least 16 bits. b. 32KB of physical memory contains 2 15 addresses, so there need to be a minimum of 15 bits in the physical address. 8.5 What is the effect of allowing... If two page table entries point to the same frame, then two pages will map to the same frame. If we need to copy the contents of a large number of pages, we can allocate a range of logical addresses and then make the page table entries for those addresses point to the data to be copied. To the process, it looks like the data has been copied, when in reality, both copies of the data refer to the same physical memory. (We use this same scheme in object-oriented programming when we avoid copying an object and instead just copy the reference to the object.) This is the technique used to implement POSIX shared memory; when two processes want to share a segment of memory, the kernel allocates pages for the shared segment, then adjusts the page tables of the two processes so that the specified logical addresses both map to the same shared physical pages. 8.9 Explain the difference between internal... Internal fragmentation is free space inside of a partition that can not be allocated for another purpose. External fragmentation is free space outside of any partition that cannot be used because it is too small.

8.10 Consider the following process for... The linkage editor must alter every address in each module to the actual physical address of the object. Since the object code is split into modules, the easiest way to do this is to calculate the offset of each address from the beginning of the module. The physical address of each object is then calculated by finding the physical address of the module and then adding the offset of the object. The compiler can help by maintaining a table that contains an entry for each object in the program that has an address. (Compiler-savvy students will recognize this data structure as a symbol table.) Each object entry consists of the name of the module that contains it, and the offset of the object within the module. 8.13 Compare the memory organization schemes... a. External fragmentation Contiguous Allocation with Fixed-Size Partitions: does not suffer from external fragmentation. Contiguous Allocation with Variable-Size Partitions: suffers from external fragmentation. Pure Segmentation: suffers from external fragmentation. Paging: does not suffer from external fragmentation. b. Internal fragmentation Contiguous Allocation with Fixed-Size Partitions: suffers from internal fragmentation. Contiguous Allocation with Variable-Size Partitions: does not suffer from internal fragmentation. Pure Segmentation: does not suffer from internal fragmentation. Paging: suffers from internal fragmentation. c. Ability to share code across processes Contiguous Allocation with Fixed-Size Partitions: no support for code sharing across processes. Contiguous Allocation with Variable-Size Partitions: no support for code sharing across processes.

Pure Segmentation: supports code sharing across processes. However, we must be careful to make sure that processes do not mix code and data in the same segment. Pure Paging: supports code sharing across processes. As in pure segmentation, we must make sure that processes do not mix code and data in the same page. 8.16 Although Android does not support... Many Android applications depend on having a known, fixed amount of space for temporary files in order to work correctly. These files are stored on the boot disk. If an Android device allowed swapping to its boot disk, the disk might become full, breaking these applications. 8.19 Program binaries in many systems... a. contiguous-memory allocation: First, assume that the size of the process s memory partition is fixed at boot time; that is, the system is using fixed-size partitions. The maximum size of the stack and heap are fixed for each process, and is calculated as the size of the partition, minus the size of the code and data segments. If the system is using variable-sized partitions, then the problem becomes more complex. A process can request a particular partition size at load time. However, if the size of the partition is too large, memory between the stack top and the end of the heap will be wasted. If the partition size is too small, the stack and the heap will collide during execution, leading to corrupted memory and a possible process crash. b. pure segmentation If the stack and heap are placed in the same segment, memory will either be wasted, or we risk the possibility of a stack/heap collision. If the stack and heap are placed in different segments, we may be able to expand the heap, but the maximum stack size is fixed at load time, since the stack grows downward. One solution on a system that uses pure segmentation is to redefine the stack to grow upwards from low memory to high.

c. pure paging Pure paging suffers from the same problem as contiguous-memory allocation, since we need to allocate a frame for each page of the process, even if the page is unused. We can solve this problem by combining paging with swapping in a scheme called virtual memory which we will study in the next chapter. 8.20 Assuming a 1-KB page size,... a. page 3, offset 13 b. page 41, offset 111 c. page 210, offset 161 d. page 634, offset 784 e. page 1953, offset 129 8.25 Consider a paging system with... a. If a memory reference takes... 100ns: 50ns to access the page table entry, plus another 50ns to access the desired memory location. Storing the page table in memory effectively halves the speed of memory under paging. b. If we add TLBs, and... The effective access time is 0.75 (2 + 50) + 0.25 (2 + 2 50) = 64.5ns. 8.28 Consider the following segment table... What are the physical addresses for the following logical addresses? a. 0,430: 649 b. 1,10: 2310 c. 2,500: Address error. The requested address is beyond the end of the segment. d. 3,400: 1727 e. 4,112: Address error. The requested address is beyond the end of the segment.

8.24 What is the purpose of... Imagine a system that allows processes to be a maximum of 16GB in size, uses 64 bit addresses, and which has 1KB pages. A 16GB process would have a maximum page table size of 16GB/1KB pages 8 bytes per page table entry = 128MB. Thus, each process requires 128MB of memory just for the page table, even if the process doesn t use all 16GB of its legal address space. For quick access, the page table must be stored in contiguous memory (like an array). Paging the page table (in combination with virtual memory, which we will study in the next chapter) allows the page table to be stored non-contiguously and allows the process to execute without the entire page table in memory.