> On Feb 16, 2017, at 6:26 PM, James K. Lowden <jklow...@schemamania.org> wrote: > > It doesn't change the fact that the OS has subverted the > guarantees your language would otherwise provide, such as the atomicity > of ++i noted elsewhere in this thread.
It’s not the OS, it’s the architecture of multiprocessor systems. A read-modify-write cycle on an address in main memory is intrinsically _not_ atomic on a multiprocessor system, not unless the CPU goes through some expensive efforts to make it so (cache invalidation, bus locking, etc.) You can get that behavior if you like by using libraries like stdatomic or the C++ atomic types, but it makes the operation much, much slower. > In > each case, at any one moment there is only one thread of control over > any given section of logic. That’s nice, but that’s just not the way the memory architectures of current computers work. Threaded programming happens to expose that behavior because it allows simultaneous read/write access to memory, and the semantics of that are subtle and weird. (It’s a distributed system after all. Distributed systems are rather Einsteinian: they don’t have strong causality.) > It's too bad they adopted threads as > their concurrency-management medium. If they'd chosen CSP instead, > maybe they wouldn't have set computing back two decades. No, they’d never have shipped a useable product. The attractive thing about threads is that they’re cheap and efficient. Higher level constructs like CSP are great, but they have a lot of overhead. For example, look at Mach: as originally implemented, it had a tiny kernel that only did message-passing, and everything else was implemented as separate processes that communicated by messaging. Unfortunately it was too slow to be useful. Every OS ever shipped by NeXT and Apple has a monolithic kernel based on BSD, with Mach messaging only used for higher-level tasks. It’s really easy to point to hard work done by other engineers and insult it without any knowledge of the actual design constraints and development issues. I hear it all the time, and personally I am sick of that attitude. —Jens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users