4 ms·
Mutexes are only ugly because few languages properly support them. It is not difficult to ensure at the language level that no object is accessed without owning
by rbehrends 13y ago
Mutexes are only ugly because few languages properly support them. It is not difficult to ensure at the language level that no object is accessed without owning the the lock associated with that object (read/write locks can be a bit trickier), but for some reason hardly any language implements something along these lines.
It's not fundamentally different from having bound checks for array indices. You can either do that pretty easily at runtime or use a simple type system to do it at compile time (e.g., Boyapati's [1] or Flanagan's [2] work). It's been done, e.g. for Cyclone [3]. This is decades old stuff, not rocket science. Honestly, Monitors had the basic idea right in the 1970s, except as Per Brinch Hansen lamented [4], language designers keep screwing it up.
[1] http://www.pmg.lcs.mit.edu/~chandra/publications/oopsla02.pdf http://www.pmg.lcs.mit.edu/~chandra/publications/oopsla02.pd...
[2] http://users.soe.ucsc.edu/~cormac/papers/esop99.pdf http://users.soe.ucsc.edu/~cormac/papers/esop99.pdf
[3] https://homes.cs.washington.edu/~djg/papers/cycthreads.pdf https://homes.cs.washington.edu/~djg/papers/cycthreads.pdf
[4] http://brinch-hansen.net/papers/1999b.pdf http://brinch-hansen.net/papers/1999b.pdf