Contributed by marco on from the random-thoughts dept.
On a different note, besides Jordan visiting, Thomas Nordin (nordin@) also showed up. He is finishing up his PhD and has not been hacking OpenBSD because of that. To keep himself sane he has done some "light reading" on Software Transactional Memory and for good measure he has also written a working implementation of this in user space. What this does is making memory writes to shared data structures behave the same way as a database writes out a record. This is all done without any locks! Here is a simple description:
- Open a handle to a shared data structure
- If its opened for writing copy the data locally
- If its opened for reading read the variables as you would as if you had locks and close the read handle
- If no one changed the global data structure from underneath you atomically replace the whole global data structure with your local copy
- If someone did change the global data structure restart the transaction
Anyway the reason i bring this up is because STM might start making its appearance in hardware in the future. The reason why this in interesting is because the current SMP locking mechanisms, big-lock and fine-grained-lock, simply suck. Big-lock hurts performance, fine-grained is too complex and puts the onus on the programmer to do it right. Not everyone can be an (instant) expert on all data structures in any given system. There are complex interactions and idiosyncrasies implicit to any system that can require a long bumpy road to learn and understand. STM does not seem to suffer from these issues. All that said I believe that locking mechanisms are bad and that we need something else. I am not smart enough to determine if it is STM but it sounds at least like a plausible alternative. Enough theoretical mambo-jambo! time will tell.
(Comments are closed)