Memory Mapped Files Using the Linux mechanism for direct access to device data.

Slides:



Advertisements
Similar presentations
Lecture 101 Lecture 10: Kernel Modules and Device Drivers ECE 412: Microcomputer Laboratory.
Advertisements

Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Discussion Week 7 TA: Kyle Dewey. Overview Midterm debriefing Virtual memory Virtual Filesystems / Disk I/O Project #3.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Linux ‘Demand-Paging’
I/O Multiplexing The role of the ‘poll()’ method in Linux device-driver operations.
The Linux PCI Interface An introduction to the PCI configuration space registers.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (4) File Management & Input/Out Systems 10/14/2008 Yang Song (Prepared.
Chapter 3 Memory Management
1 Outline File Systems Implementation How disks work How to organize data (files) on disks Data structures Placement of files on disk.
A device-driver for Video Memory Introduction to basic principles of the PC’s graphics display.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
The ‘mmap()’ method Adding the ‘mmap()’ capability to our ‘vram.c’ device-driver.
File System Implementation
Silberschatz, Galvin and Gagne  Operating System Concepts Common System Components Process Management Main Memory Management File Management.
1 Memory Management in Representative Operating Systems.
Word Processing, Web Browsing, File Access, etc. Windows Operating System (Kernel) Window (GUI) Platform Dependent Code Virtual Memory “Swap” Block Data.
System Software, functions of an operating system
What do operating systems do? manage processes manage memory and computer resources provide security features execute user programs make solving user.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Memory Mapping Sarah Diesburg COP5641.
Virtual Memory.
Chapter 1. Introduction What is an Operating System? Mainframe Systems
Block I/O. 2 Definition Any I/O operation in which the unit of data is several words, not just one word or byte.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
Microprocessor-based systems Curse 7 Memory hierarchies.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
Digital imaging. Two types of graphic Bitmap Vector.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Chapter 4 Memory Management Virtual Memory.
1 Advanced Memory Management Techniques  static vs. dynamic kernel memory allocation  resource map allocation  power-of-two free list allocation  buddy.
University of Amsterdam Computer Systems – virtual memory Arnoud Visser 1 Computer Systems Virtual Memory.
Introduction to Virtual Memory and Memory Management
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13.
What is a Process ? A program in execution.
Test for timestamp : measure code execution time.
Kernel Modules – Introduction CSC/ECE 573, Sections 001 Fall, 2012.
Why Kernel Works? kernel function gets dynamic memory in a fairly straightforward manner _get_free_pages( ) or alloc_pages( ) The simple approaches work.
File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314.
Operating System (Reference : OS[Silberschatz] + Norton 6e book slides)
Virtual Memory By CS147 Maheshpriya Venkata. Agenda Review Cache Memory Virtual Memory Paging Segmentation Configuration Of Virtual Memory Cache Memory.
Virtual Memory – Paging Techniques
Introduction to Operating Systems Concepts
Input/Output (I/O) Important OS function – control I/O
Input/Output Device Drivers
MODERN OPERATING SYSTEMS Third Edition ANDREW S
3.3 Fundamentals of data representation
Session 3 Memory Management
Chapter 12: File System Implementation
FileSystems.
Chapter 4 – Introduction to Operating System Concepts
Linux Operating System Architecture
Operation System Program 4
O.S Lecture 13 Virtual Memory.
Chapter 2: System Structures
SWE3015 Operating System Project Assignment 2 박은수, 박경원, 김지원
Direct Memory Access Introduction
Operating Systems.
What Happens if There is no Free Frame?
Virtual Memory.
Virtual Memory: Systems CSCI 380: Operating Systems
Computer System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Virtual Memory and Paging
Dirty COW Race Condition Attack
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Memory Mapped Files Using the Linux mechanism for direct access to device data

Typical file access senario Use open(), lseek(), read(), write(), close() Each involves two privilege-transitions At most 4096 bytes transferred each time Inefficient for non-sequential data access

Alternative: use ‘mmap()’ Take advantage of the paging mechanism Associate virtual addresses with the data Similar to ‘swapping’ or ‘page-cacheing’ Simple standard C programming API: –‘mmap()’ creates the memory mapping –‘munmap()’ deletes the memory mapping Example: look at ‘dump.cpp’ on website

Four easy steps 1) open the file 2) map the file 3) use the file 4) unmap the file and close the file

Device memory mapping Recall our ‘vram.c’ character driver Allowed users to access display memory But lacks efficiency for serious graphics We implement driver ‘mmap()’ method

‘mmap()’ driver-method Ideas from LDD textbook: Chapter 13 But also required lots of experimentation Four steps in the ‘mmap()’ method 1) compute map’s starting-point and length 2) check: cannot map past end-of-memory 3) mark mapped area as ‘non-swappable’ 4) request kernel to set up the page-tables

Information from vm_area_struct ‘vm_start’ is starting address in user-space ‘vm_end’ is ending address in user-space ‘vm_pgoff’ is page-offset in device memory ‘vm_page_prot’ is page-protection bitmap ‘vm_flags’ is bitmap of requested attributes ‘EAGAIN’ error-code tells kernel ‘try again’

Comparing execution-times We ccan use our ‘tsc.c’ device-driver Step 1: read and save timestamp counter Step 2: perform our drawing operations Step 3: read and save timestamp counter Step 4: subtract timestamp counter values Step 5: report the number of CPU cycles