The ‘mmap()’ method Adding the ‘mmap()’ capability to our ‘vram.c’ device-driver.

Slides:



Advertisements
Similar presentations
Linux ‘Demand-Paging’
Advertisements

Daemon Processes Long lived utility processes Often started at system boot and ended when system shuts down Run in the background with no controlling terminal.
CS 686: Programming SuperVGA Graphics Devices Introduction: An exercise in working with graphics file formats.
Linking, Loading and Mapping A look at how Operating System utilities and services support application deployment.
Instructors: Randy Bryant and Dave O’Hallaron
Read vs. mmap Tan Li. Man mmap #include void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset); int munmap(void *start, size_t.
Linux Memory Issues An introduction to some low-level and some high-level memory management concepts.
SiS 315 Graphics Engine Introduction to some capabilities of graphics accelerator hardware.
Standard C Libraries Application Programmming Interface to System-Calls.
Linux Memory Management High-Level versus Low-Level.
“Virtual” Memory How does the OS kernel provide “private” and “shared” memory areas to multiple concurrent processes?
The ‘ioctl’ driver-function On implementing ‘show’ and ‘hide’ for the SiS 315 hardware cursor.
Direct I/O Programming An introduction to the Pentium’s mechanism for programming peripheral hardware components.
Standard C Library Application Programming Interface to System-Calls.
P6/Linux Memory System Oct. 31, 2002
The ‘ioctl’ driver-function On implementing a way to query and modify our UART’s baudrate via the ‘device-file’ abstraction.
A device-driver for Video Memory Introduction to basic principles of the PC’s graphics display.
Memory System Case Studies Oct. 28, 2004 Topics P6 address translation x86-64 extensions Linux memory management Linux page fault handling Memory mapping.
Linux Memory Management How does the Linux kernel keep track of the Virtual Memory Areas that each process uses?
– 1 – P6 (PentiumPro,II,III,Celeron) memory system bus interface unit DRAM Memory bus instruction fetch unit L1 i-cache L2 cache cache bus L1 d-cache inst.
Notes for Lab 10 On implementing ‘show’ and ‘hide’ for the SiS 315 hardware cursor.
Memory Mapping Sarah Diesburg COP5641.
Memory Mapped Files Using the Linux mechanism for direct access to device data.
1 Virtual Memory: Systems Level Andrew Case Slides adapted from jinyang Li, Randy Bryant and Dave O’Hallaron.
CS 241 Fall 2007 System Programming 1 Virtual Memory Lawrence Angrave and Vikram Adve.
NCHU System & Network Lab Lab 11 Memory Mapped File.
1 Shared Memory. 2  Introduction  Creating a Shared Memory Segment  Shared Memory Control  Shared Memory Operations  Using a File as Shared Memory.
Memory System Case Studies Oct. 31, 2007 Topics P6 address translation x86-64 extensions Linux memory management Linux page fault handling Memory mapping.
CSNB334 Advanced Operating Systems 4. Concurrency : Mutual Exclusion and Synchronization.
University of Amsterdam Computer Systems – virtual memory Arnoud Visser 1 Computer Systems Virtual Memory.
CS 105 “Tour of the Black Holes of Computing!”
Carnegie Mellon 1 Virtual Memory: Systems / : Introduction to Computer Systems 17 th Lecture, Oct. 27, 2011 Instructors: Dave O’Hallaron,
1 Virtual Memory. 2 Outline Multilevel page tables Different points of view Pentium/Linux Memory System Memory Mapping Suggested reading: 10.6, 10.3,
P6/Linux Memory System Topics P6 address translation Linux memory management Linux page fault handling memory mapping vm2.ppt CS 105 “Tour of the Black.
What is a Process ? A program in execution.
1 Virtual Memory. 2 Outline Multilevel page tables Different points of view Pentium/Linux Memory System Memory Mapping Suggested reading: 10.6, 10.3,
Carnegie Mellon 1 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Virtual Memory: Systems CENG331 - Computer Organization.
Carnegie Mellon 1 Virtual Memory: Systems / : Introduction to Computer Systems 17 th Lecture, Mar. 19, 2015 Instructors: Seth Copen Goldstein,
Why Kernel Works? kernel function gets dynamic memory in a fairly straightforward manner _get_free_pages( ) or alloc_pages( ) The simple approaches work.
 Backlight 에서 나온 백색광이 액정 셀을 통과하면 서 투과율이 조절되고 red, green, blue 의 color filter 를 투과해 나오는 빛의 혼합을 통해 색이 구 성됨  Color filter 는 셀사이의 빛을 차단하는 black matrix,
Memory Management 백 일 우
Virtual Memory: Systems
Lecture 10 Memory management Nov. 17, 2015 Kyu Ho Park.
Virtual Memory Alan L. Cox Some slides adapted from CMU slides.
Lecture 24 – Paging implementation
CS 140 Lecture Notes: Virtual Memory
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
Virtual Memory: Systems
Andrew Hanushevsky: Memory Mapped I/O
Virtual Memory: Concepts CENG331 - Computer Organization
Virtual Memory: Systems /18-213/14-513/15-513: Introduction to Computer Systems 18th Lecture, October 25, 2018.
CS 140 Lecture Notes: Virtual Memory
Virtual Memory: Systems
Virtual Memory: Systems
Making Virtual Memory Real: The Linux-x86-64 way
Memory System Case Studies Oct. 13, 2008
Pentium/Linux Memory System
P6 (PentiumPro,II,III,Celeron) memory system
CS 140 Lecture Notes: Virtual Memory
Pentium III / Linux Memory System April 4, 2000
Virtual Memory.
Instructor: Phil Gibbons
Virtual Memory: Systems CSCI 380: Operating Systems
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
CS 140 Lecture Notes: Virtual Memory
CS 105 “Tour of the Black Holes of Computing!”
Dirty COW Race Condition Attack
P6 (PentiumPro,II,III,Celeron) memory system
Presentation transcript:

The ‘mmap()’ method Adding the ‘mmap()’ capability to our ‘vram.c’ device-driver

Purpose of ‘mmap()’ The ‘mmap()’ system-call creates a new region in the task’s virtual memory map, and associates that region with a file (or with a device-file such as ‘/dev/vram’) It returns a pointer to this memory area Thus it allows the program to access the file as if it were an array in user-space Avoids ‘read()’ and ‘write()’ system-calls

Mapping vram to userspace virtual address-space physical address-space HIGHMEM ZONE NORMAL Kernel Text/Data VRAM Kernel space User space STACK TEXT/DATA RUNTIME LIBRARIES m map()

‘mmap()’ syntax void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset );

The ‘page-protection’ bits PROT_READ PROT_WRITE PROT_EXEC PROT_NONE

The ‘flags’ bits MAP_SHARED MAP_PRIVATE MAP_FIXED MAP_ANONYMOUS MAP_GROWSDOWN MAP_DENYWRITE MAP_EXECUTABLE MAP_LOCKED MAP_NORESERVE MAP_POPULATE MAP_NONBLOCK

The region to be mapped offset start (virtual address) file region to be mapped length Total extent of the file

Kernel data-structures task_struct mm mm_struct page directory pgd_t pgd vma vm_start vm_end vm_area_struct vm_start vm_end

The ‘munmap()’ syntax int munmap( void *start, int length );

Demo-program: ‘vrammdraw’ We added ‘my_mmap()’ to our ‘vram.c’ device-driver (calling it ‘vramm.c’) We wrote an application (actually a new version of our ‘vramdraw.cpp’ program) that calls our driver’s ‘mmap()’ method You can try it out – it’s on class website

In-class exercise #1 Write a new version of our ‘grabber1.cpp’ and ‘grabber2.cpp’ demo-programs which will ‘grab’ a screen-image and write it out to a file, but will NOT make system-calls to ‘read()’ from the ‘/dev/vram’ device-file (it will instead use ‘mmap()’ to map the video display memory into user-space so it can be accessed just like an ordinary array)

In-class exercise #2 Use the Linux ‘time’ command to compare the execution-speed of your ‘grabber3’ to observed speeds of ‘grabber1’, ’grabber2’