Managing Caching for I/O. Jeff Chase Duke University. Memory as a cache. Processes access external storage objects through file APIs and VM abstraction. The OS kernel manages caching of pages/blocks in main memory. virtual address spaces. data. data. files and filesystems, databases,
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Processes access external storage objects through file APIs and VM abstraction. The OS kernel manages caching of pages/blocks in main memory.
virtual address spaces
files and filesystems,
other storage objects
disk and other storage
backing storage volumes
(pages and blocks)
page/block read/write accesses
File abstraction implemented in upper DFS layer.
All knowledge of how files are laid out on disk is at this layer.
Access underlying disk volume through buffer cache API.
Obtain buffers (dbufs), write/read to/from buffers, orchestrate I/O.
DBuffer dbuf = getBlock(blockID)
Device I/O interface
Asynchronous I/O to/from buffers
block read and write
Blocks numbered by blockIDs
create, destroy, read, write a dfile
1. Fetch blocks for data and metadata (or zero new ones fresh) into cache buffers (dbufs).
2. Copy bytes to/from dbufs with read and write.
3. Track which data/metadata blocks are valid, and which valid blocks are clean and which are dirty.
4. Clean the dirty blocks by writing them back to the disk with push.
DBuffer dbuf = getBlock(blockID)
List(s) of free buffers (bufs) or eviction candidates. These dbufs might be listed in the cache directory if they contain useful data, or not, if they are truly free.
To replace a dbuf
Remove from free/eviction list.
Remove from cache directory.
Change dbuf blockID and status.
Enter in directory w/ new blockID.
Re-register on eviction list.
Beware of concurrent accesses.
3. getBlock for maps,traverse cached maps, getBlock for data, andstart fetch.
6. Return to user program.
2. Enter kernel for read syscall.
5. Copy data to user buffer in read.
4. sleep for I/O (stall)
1. Detect access pattern.
Reduce I/O stalls
2. Start prefetching
App requests block n
App requests block n+1
System prefetches block n+2
System prefetches block n+3
Each thread/process/job utters a stream of page/block references.
The OS tries to minimize the number of fetches/faults.
Replacement policy is the key.
X Y Z A Z B C D E Z A B C D E
Each process/VAS has its own page table. Virtual addresses are translated relative to the current page table.
process page table (map)
In this example, each VPN j maps to PFN j, but in practice any physical frame may be used for any virtual page.
The maps are themselves stored in memory; a protected register holds a pointer to the current map.
user virtual address
Two-level page tables
Example: typical 32-bit
architecture with 4KB pages.
Virtual address translation maps a virtual page number (VPN) to a physical page frame number (PFN): the rest is easy.
Deliver exception to
OS if translation is not
valid and accessible in
Threads in an address space may change their working sets.
This is a plot of selected internal kernel events during a run of a process that randomly reads/writes its virtual memory.
The machine is an Alpha with 8000 8KB pages (64MB total)
The process uses 48MB of virtual memory: force the paging daemon to do FIFO-2C bookkeeping, but little actual paging.