DOC PREVIEW
USF CS 635 - Memory Mapped Files

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 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 8 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 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Memory Mapped FilesTypical file access senarioAlternative: use ‘mmap()’Four easy stepsDevice memory mapping‘mmap()’ driver-methodInformation from vm_area_structComparing execution-timesMemory Mapped FilesUsing the Linux mechanism for direct access to device dataTypical 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 accessAlternative: 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 websiteFour easy steps•1) open the file•2) map the file•3) use the file•4) unmap the file and close the fileDevice 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()’ method1) compute map’s starting-point and length2) check: cannot map past end-of-memory3) mark mapped area as ‘non-swappable’4) request kernel to set up the page-tablesInformation 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


View Full Document

USF CS 635 - Memory Mapped Files

Download Memory Mapped Files
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 Memory Mapped Files 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 Memory Mapped Files 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?