% scalable virtual memory w/ RCU # administrivia project proposal due this Friday 11pm work in groups (preferred; not required) close to your research talk to us # today's plan virtual address space read-copy-update (RCU) functional data structure # "big" questions Q1: what's the problem & for what kind of applications? Q2: is this the "right" solution for this problem? multithreaded, VM-intensitve apps? compare to exokernel/library OS (e.g., Corey, Barrelfish)? # memory mapping app ↔ kernel: mmap/munmap kernel ↔ hw: pagefault `cat /proc/self/maps` virtual memory areas (VMAs): list (traverse) & tree (lookup) tree examples: rb (linux), avl (windows), splay (freebsd) # concurrency quiz: output? ```c++ #include #include static int flag = 0; void signal_proc() { // t1 std::cout << "before signal" << std::endl; flag = 1; } void wait_proc() { // t2 while (flag == 0) {} std::cout << "after wait" << std::endl; } int main() { std::thread t1(signal_proc), t2(wait_proc); t1.join(); t2.join(); } ``` . . . undefined behavior: `g++-4.9 -O2`, infinite loop # concurrency primitives atomic reads/writes, memory barriers mutual exclusion rw locks: concurrent reads; reads/write block each other RCU: wait-free reads; single pointer update; delay free RCU-friendly balanced trees: eliminate read locks see also: [rcutorture](https://www.kernel.org/doc/Documentation/RCU/torture.txt), [verification challenge](http://paulmck.livejournal.com/tag/rcu) # functional data structures path copying: slist, tree optimization in bonsai tree: update non-root pointers other apps: file snapshots (btrfs), model checking (klee)