robert-strandh/McCLIM — pull request #2 by mtstickney (2014-01-22 20:59:33+00:00)
Title: Use sb-threads:with-mutex wherever possible, protect atomic sections with without-interrupts

Looking at the SBCL source, get-mutex and grab-mutex differ only in how they handle the owner parameter, which was removed in grab-mutex. It would be safe to replace get-mutex with grab-mutex, but neither is interrupt-safe.

This is a fairly aggressive set of changes that use with-mutex wherever possible, and that should fix some existing interrupt-safety issues with the code. The main issue is that unwind-protect is not safe with interrupts -- for example, if sb-thread:terminate-process interrupts a thread in the body of unwind-protect, the cleanup form won't be run unless it was protected with without-interrupts. I believe all the code in here is now interrupt-safe, though the code running in the threads is still vulnerable.

As I mentioned on #lisp, I'm not an SBCL or threading expert, so take what I say with a grain of salt. My biggest concern here is that the yield in process-wait and process-wait-with-timeout won't play nicely with without-interrupts, though I don't have a specific reason to think it wouldn't.