PS3 Reference Solution

Posted: Wed 02 April 2014

The reference solution for Problem Set 3 is now available: (Sorry for not posting it earlier!)

The main things that Weilin did to make it perform well (in addition to the improvements described in the PS3 problems) was to always use an RWArc or MutexArc to control the access to shared data keeping the critical section as short as possible. This is especially important for the cache. Solutions that locked the cache while a new file is read from disk often ended up slower than a solution with no caching, since all other tasks were stuck waiting for the thread reading the file to complete. It is, though, not necessary to keep the cache locked while a file is being read. Instead, it is only necessary to lock the cache for the short time needed to add that file to the cache. (There is some risk that two tasks would end up reading the same file, which is wasteful, but rare, and still much better than locking the cache for the whole read time.)