Studying ‘mmap()/munmap()’ How we can use our ‘toolbox’ of effects of ‘mmap()/munmap()’
Download ReportTranscript Studying ‘mmap()/munmap()’ How we can use our ‘toolbox’ of effects of ‘mmap()/munmap()’
Studying ‘mmap()/munmap()’ How we can use our ‘toolbox’ of kernel modules to examine the effects of ‘mmap()/munmap()’ Experiment #1 • • • • • Remember our ‘vma.c’ module? It creates a ‘/proc’ file It shows a task’s virtual memory areas NOTE: It works only for the ‘current’ task We do BEFORE and AFTER comparisons Details of our Plan #1 • Install the ‘vma.c’ module • Install ‘mysis.c’ device-driver • Write an application: ‘mmstudy1.cpp’ – Open the files ‘/dev/mysis’ and ‘/proc/vma’ – Read and display contents of ‘/proc/vma’ – Call ‘mmap()’ to map the video frame-buffer – Read and display contents of ‘/proc/vma’ – Call ‘munmap()’ to unmap the frame-buffer – Read and display contents of ‘/proc/vma’ Experiment #2 • • • • • • We want to examine a task’s page-tables We need to use our ‘ram.c’ device-driver We also need a new ‘/proc’ file: ‘cr3.c’ CR3 = physical address of page-directory Page-Directory = page-table addresses We again do BEFORE and AFTER looks Details of our Plan #2 • Install modules ‘cr3.c’ and ‘ram.c’ • Write an application: ‘mmstudy2.cpp’ – Open: /proc/cr3, ‘/dev/ram’ and ‘/dev/vram’ – Read page-directory and page-table(s) – Call ‘mmap()’ to map the video frame-buffer – Read page-directory and page-table(s) – Call ‘munmap()’ to unmap the frame-buffer – Read page-directory and page-table(s) – Compare tables (to see if anything changed) What to turn in today? • Turn in a printout of your source-code: – for ‘mmstudy1.cpp’ and for ‘mmstudy2.cpp’ • Turn in a printout of your program output: – from ‘mmstudy1’ and from ‘mmstudy2’ • You may ask for assistance – from Instructor, from TA, from classmembers