DOC PREVIEW
USF CS 635 - The mmap method

This preview shows page 1-2-3-4 out of 12 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

The ‘mmap()’ methodPurpose of ‘mmap()’Mapping vram to userspace‘mmap()’ syntaxThe ‘page-protection’ bitsThe ‘flags’ bitsThe region to be mappedKernel data-structuresThe ‘munmap()’ syntaxDemo-program: ‘vrammdraw’In-class exercise #1In-class exercise #2The ‘mmap()’ methodAdding the ‘mmap()’ capability to our ‘vram.c’ device-driverPurpose 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-callsMapping vram to userspace virtualaddress-space physicaladdress-spaceHIGHMEMZONENORMALKernelText/DataVRAMVRAMKernelspace UserspaceSTACKTEXT/DATARUNTIMELIBRARIESm 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_NONEThe ‘flags’ bits•MAP_SHARED•MAP_PRIVATE•MAP_FIXED•MAP_ANONYMOUS•MAP_GROWSDOWN•MAP_DENYWRITE•MAP_EXECUTABLE•MAP_LOCKED•MAP_NORESERVE•MAP_POPULATE•MAP_NONBLOCKThe region to be mappedoffset start(virtual address)file region to be mappedlengthTotal extent of the fileKernel data-structurestask_structmmmm_structpagedirectory pgd_tpgdvmavm_start vm_endvm_area_structvm_start vm_endvm_start vm_endvm_start vm_endvm_start vm_endvm_start vm_endvm_start vm_endThe ‘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 websiteIn-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’,


View Full Document

USF CS 635 - The mmap method

Download The mmap method
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view The mmap method and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The mmap method 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?