












































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













































































Jonathan Walpole Computer Science Portland State University
Memory mapped files Avoid system call overhead Buffer cache Avoid disk I/O overhead Careful data placement on disk Avoid seek overhead Log structured file systems Avoid seek overhead for disk writes (reads hit in buffercache)
Place the file in the “virtual” address space Each byte in a file has a virtual address
Just load that byte’s virtual address
Calculated from the starting virtual address of the fileand the offset of the byte in the file Kernel will fault in pages from disk when needed
Just store bytes to the right memory locations Open & Close syscalls
Map & Unmap syscalls
Virtual Address Space Stack Text & Data File on Disk
Virtual Address Space Stack Text & Data File on Disk “Map” syscall is made
Virtual Address Space Stack Text & Data File on Disk “Map” syscall is made
So how does memory mapping a file affect performance?
Observations: Once a block has been read into memory it can be used toservice subsequent read/write requests without going todisk Multiple file operations from one process may hit thesame file block File operations of multiple processes may hit the samefile block Idea: maintain a “
memory When a process tries to read a block check the cachefirst
Cache organization: Many blocks (e.g., 1000s) Indexed on block number For efficiency, use a hash table device block# key
Need to write a block? Modify the version in the block cache. But when should we write it back to disk? Immediately Later
Need to write a block? Modify the version in the block cache. But when should we write it back to disk? Immediately
“ Write-through cache” Later - The Unix “sync” syscall
Need to write a block? Modify the version in the block cache. But when should we write it back to disk? Immediately
“ Write-through cache” Later - The Unix “synch” syscall
Write directory and i-node info immediately Okay to delay writes to files
Background process to write dirty blocks