HY345 Operating Systems



Similar documents
Operating Systems. Virtual Memory

COMPUTER ORGANIZATION ARCHITECTURES FOR EMBEDDED COMPUTING

Lecture 17: Virtual Memory II. Goals of virtual memory

Memory Management Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging

OPERATING SYSTEM - VIRTUAL MEMORY

Computer Architecture

Operating Systems, 6 th ed. Test Bank Chapter 7

Bindel, Spring 2010 Applications of Parallel Computers (CS 5220) Week 1: Wednesday, Jan 27

Analysis of Binary Search algorithm and Selection Sort algorithm

Chapter 12. Paging an Virtual Memory Systems

Chapter 10: Virtual Memory. Lesson 08: Demand Paging and Page Swapping

Java Virtual Machine: the key for accurated memory prefetching

Virtual Memory Paging

Binary search tree with SIMD bandwidth optimization using SSE

İSTANBUL AYDIN UNIVERSITY

Memory Systems. Static Random Access Memory (SRAM) Cell

Virtual Memory. Virtual Memory. Paging. CSE 380 Computer Operating Systems. Paging (1)

& Data Processing 2. Exercise 3: Memory Management. Dipl.-Ing. Bogdan Marin. Universität Duisburg-Essen

Analysis of Memory Sensitive SPEC CPU2006 Integer Benchmarks for Big Data Benchmarking

Subject knowledge requirements for entry into computer science teacher training. Expert group s recommendations

Computer Organization and Architecture. Characteristics of Memory Systems. Chapter 4 Cache Memory. Location CPU Registers and control unit memory

THE NAS KERNEL BENCHMARK PROGRAM

Attaining EDF Task Scheduling with O(1) Time Complexity

Hardware Assisted Virtualization

Testing and Inspecting to Ensure High Quality

COS 318: Operating Systems. Virtual Memory and Address Translation

Hardware-Aware Analysis and. Presentation Date: Sep 15 th 2009 Chrissie C. Cui

Matrix Multiplication

Unit 1: Family Letter

Lecture 16: Storage Devices

CPU Performance. Lecture 8 CAP

Efficiency of algorithms. Algorithms. Efficiency of algorithms. Binary search and linear search. Best, worst and average case.

CS 61C: Great Ideas in Computer Architecture Virtual Memory Cont.

Memory unit sees only the addresses, and not how they are generated (instruction counter, indexing, direct)

Data Storage - II: Efficient Usage & Errors

EFFICIENT EXTERNAL SORTING ON FLASH MEMORY EMBEDDED DEVICES

Improving the Performance of Hypervisor-Based Fault Tolerance

Motorola 8- and 16-bit Embedded Application Binary Interface (M8/16EABI)

Board Notes on Virtual Memory

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

Using Synology SSD Technology to Enhance System Performance. Based on DSM 5.2

CS 6290 I/O and Storage. Milos Prvulovic

Chapter 11 I/O Management and Disk Scheduling

Memory management basics (1) Requirements (1) Objectives. Operating Systems Part of E1.9 - Principles of Computers and Software Engineering

Confinement Problem. The confinement problem Isolating entities. Example Problem. Server balances bank accounts for clients Server security issues:

Windows Server Performance Monitoring

PROBLEMS (Cap. 4 - Istruzioni macchina)

Chapter 11 I/O Management and Disk Scheduling

Storing Data: Disks and Files

Memory Hierarchy. Arquitectura de Computadoras. Centro de Investigación n y de Estudios Avanzados del IPN. adiaz@cinvestav.mx. MemoryHierarchy- 1

Page Replacement for Write References in NAND Flash Based Virtual Memory Systems

EE8205: Embedded Computer System Electrical and Computer Engineering, Ryerson University. Multitasking ARM-Applications with uvision and RTX

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Computer Architecture

On Demand Loading of Code in MMUless Embedded System

ENGI E1112 Departmental Project Report: Computer Science/Computer Engineering

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

Chapter 13 File and Database Systems

Chapter 13 File and Database Systems

Secondary Storage. Any modern computer system will incorporate (at least) two levels of storage: magnetic disk/optical devices/tape systems

CSE 6040 Computing for Data Analytics: Methods and Tools

Introduction. What is RAID? The Array and RAID Controller Concept. Click here to print this article. Re-Printed From SLCentral

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

Midterm Exam #2 Solutions November 10, 1999 CS162 Operating Systems

A3 Computer Architecture

EMC Publishing. Ontario Curriculum Computer and Information Science Grade 11

Midterm Exam #2 November 10, 1999 CS162 Operating Systems

CS 147: Computer Systems Performance Analysis

Virtualization. Explain how today s virtualization movement is actually a reinvention

Quiz for Chapter 1 Computer Abstractions and Technology 3.10

The Classical Architecture. Storage 1 / 36

1 The Java Virtual Machine

Testing Database Performance with HelperCore on Multi-Core Processors

Image Compression through DCT and Huffman Coding Technique

The Big Picture. Cache Memory CSE Memory Hierarchy (1/3) Disk

Spring 2011 Prof. Hyesoon Kim

Describe the process of parallelization as it relates to problem solving.

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

File Management. Chapter 12

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

361 Computer Architecture Lecture 14: Cache Memory

Slide Set 8. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng

IMPROVING PERFORMANCE OF RANDOMIZED SIGNATURE SORT USING HASHING AND BITWISE OPERATORS

Efficient Iceberg Query Evaluation for Structured Data using Bitmap Indices

find model parameters, to validate models, and to develop inputs for models. c 1994 Raj Jain 7.1

Chapter 6: Programming Languages

A Dynamic Programming Approach for Generating N-ary Reflected Gray Code List

Virtual vs Physical Addresses

Deploying De-Duplication on Ext4 File System

PROBLEMS #20,R0,R1 #$3A,R2,R4

2

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Resource Allocation Schemes for Gang Scheduling

1 File Processing Systems

Data Backup and Archiving with Enterprise Storage Systems

Transcription:

HY345 Operating Systems Recitation 2 - Memory Management Solutions Panagiotis Papadopoulos panpap@csd.uoc.gr

Problem 7 Consider the following C program: int X[N]; int step = M; //M is some predefined constant for (int i = 0; i < N; i += step) X[i] = X[i] + 1 ; a) If this program is run on a machine with a 4-KB page size and 64-entry TLB, what values of M and N will cause a TLB miss for every execution of the inner loop? b) Would your answer in part (a) be different if the loop were repeated many times? Explain. a) M has to be at least 4,096 to ensure a TLB miss for every access to an element of X. Since N only affects how many times X is accessed, any value of N will do. b) M should still be at least 4,096 to ensure a TLB miss for every access to an element of X. But now N should be greater than 64K to thrash the TLB, that is, X should exceed 256 KB.

PROBLEM 9 A machine has a 32-bit address space and an 8-KB page. The page table is entirely in hardware, with one 32-bit word per entry. When a process starts, the page table is copied to the hardware from memory, at one word every 100 nsec. If each process runs for 100 msec (including the time to load the page table), what fraction of the CPU time is devoted to loading the page tables? The page table contains 2^32 /2^13 entries, which is 524,288. Loading the page table takes 52 msec. If a process gets 100 msec, this consists of 52 msec for loading the page table and 48 msec for running. Thus 52% of the time is spent loading page tables.

PROBLEM 16 The TLB on the VAX does not contain an R bit. Why? The R bit is never needed in the TLB. The mere presence of a page there means the page has been referenced; otherwise it would not be there. Thus the bit is completely redundant. When the entry is written back to memory, however, the R bit in the memory page table is set.

PROBLEM 20 A student in a compiler design course proposes to the professor a project of writing a compiler that will produce a list of page references that can be used to implement the optimal page replacement algorithm. Is this possible? Why or why not? Is there anything that could be done to improve paging efficiency at run time? This is probably not possible except for the unusual and not very useful case of a program whose course of execution is completely predictable at compilation time. If a compiler collects information about the locations in the code of calls to procedures, this information might be used at link time to rearrange the object code so that procedures were located close to the code that calls them. This would make it more likely that a procedure would be on the same page as the calling code. Of course this would not help much for procedures called from many places in the program.

PROBLEM 21 Suppose that the virtual page reference stream contains repetitions of long sequences of page references followed occasionally by a random page reference. For example, the sequence: 0, 1,..., 511, 431, 0, 1,..., 511, 332, 0, 1,... consists of repetitions of the sequence 0, 1,..., 511 followed by a random reference to pages 431 and 332. a) Why won't the standard replacement algorithms (LRU, FIFO, Clock) be effective in handling this workload for a page allocation that is less than the sequence length? b) If this program were allocated 500 page frames, describe a page replacement approach that would perform much better than the LRU, FIFO, or Clock algorithms. a. Every reference will page fault unless the number of page frames is 512, the length of the entire sequence. b. If there are 500 frames, map pages 0 498 to fixed frames and vary only one frame.

PROBLEM 29 Consider the following two-dimensional array: int X[64][64]; Suppose that a system has four page frames and each frame is 128 words (an integer occupies one word). Programs that manipulate the X array fit into exactly one page and always occupy page 0. The data are swapped in and out of the other three frames. The X array is stored in row-major order (i.e., X[0][1] follows X[0][0] in memory). Which of the two code fragments shown below will generate the lowest number of page faults? Explain and compute the total number of page faults. Fragment A for (int j=0; j<64; j++) for (int i=0; i<64; i++) X[i][j]=0; Fragment B for (int i=0; i<64; i++) for (int j=0; j<64; j++) X[i][j]=0; Fragment B since the code has more spatial locality than Fragment A. The inner loop causes only one page fault for every other iteration of the outer loop. (There will only be 32 page faults.) Aside (Fragment A): Since a frame is 128 words, one row of the X array occupies half of a page (i.e., 64 words). The entire array fits into 64 32/128 = 16 frames. The inner loop of the code steps through consecutive rows of X for a given column. Thus every other reference to X [i ][j ] will cause a page fault. The total number of page faults will be 64 64/2 = 2,048.

PROBLEM 34 A group of operating system designers for the Frugal Computer Company are thinking about ways to reduce the amount of backing store needed in their new operating system. The head guru has just suggested not bothering to save the program text in the swap area at all, but just page it in directly from the binary file whenever it is needed. Under what conditions, if any, does this idea work for the program text? Under what conditions, if any, does it work for the data? It works for the program if the program cannot be modified. It works for the data if the data cannot be modified. However, it is common that the program cannot be modified and extremely rare that the data cannot be modified. If the data area on the binary file were overwritten with updated pages, the next time the program was started, it would not have the original data.

PROBLEM 38 Can you think of any situations where supporting virtual memory would be a bad idea, and what would be gained by not having to support virtual memory? Explain. General virtual memory support is not needed when the memory requirements of all applications are well known and controlled. Some examples are special- purpose processors (e.g., network processors), embedded processors, and super-computers (e.g., airplane wing design). In these situations, we should always consider the possibility of using more real memory. If the operating system did not have to support virtual memory, the code would be much simpler and smaller. On the other hand, some ideas from virtual memory may still be profitably exploited, although with different design requirements. For example, program/thread isolation might be paging to flash memory