People don’t write enough multi-threaded code

There’s an article on Computerworld that Microsoft is telling us that multicore chips are changing PC software design, but that not enough people are programming multi-threaded applications to take advantage of this feature.
Let me tell you, writing multi-threaded code is really easy. Writing correct multi-threaded code is the tricky part. Most development frameworks are not Multi-Thread safe. This means that you can’t use it willy-nilly from multiple threads at the same time (it’s primarily a resource assignment issue). So you have one thread that performs all the GUI work. Then you have to coordinate to have either the data or something close to rendered detail for the GUI thread. Then you have a barrage of threads performing various other bits of work. Of course, don’t forget that making an application too multi-threaded has negative effects.
There is a subtle difference between multi-processor and multi-threaded processors which means that an mt-processor isn’t the same functionally as separate cores/processors (shared resources, this being the whole -threading implication behind the name), so just throwing arbitrarily extra work at the mt-processor won’t gain you much. The OS needs to know this information to schedule more intelligently, so adorning the threads with informatiion about the related data-affinity can gain you significant performance boosts (the OS schedules different threads more intelligently). The problem is that you need to export this concept to an application programmer. Guess what, it’s generally too complicated for anything less than the most processor intensive tasks.
Generally, having the extra threads/cores/processors means that you get an overall system performance boost, it’s just that the OS stops the isolation granularity at the process level. Operating systems have been designed around the ‘complicated process, simple thread’ principle. You don’t want to change the balance of complexity moving back into the threads, we’ll just end up with a sub-thread concept, and my head just hurts from that (atoms, quantum elements).
So what does the average joe programmer do? How do you find places that are suitable for parallelizing? How do you then ‘fix’ them up? Well, unless your program needs parallelism in the first place, it’s actually difficult to retrofit it into a pre-existing design.
Well, there’s a ton more stuff on this that I would like to get down, but it’s 2am, and I need to get some sleep. More in the morrow.

One Reply to “People don’t write enough multi-threaded code”

  1. For something written at 2am in the morning it reads rather good. Nice one Pete.

Comments are closed.