Multi-threading woes

Multi-threading is quite possibly the most misunderstood concept from a consumer’s stand-point in computer science. I can’t even count the number of times I’ve heard statements such as “what’s the point with 4 cores, when current programs only supports two cores?”. So I thought I’d take it upon myself to clear this up, once and for all. No (sane) application is written for two, four or <insert arbitrary number> cores. Either it supports multiple cores, or it supports one. There’s no in-between. A well-written multi-threaded application will have a significant performance gain for each core you toss at it! Why? Well this is very simple; from an application stand-point, the CPU is completely abstract. The OS handles all the task scheduling, including threading. So in the program, I would just say “hey, I need another thread for doing some fancy-pansy time consuming quantum physics math”, and the OS will open up a new thread which may run on another core than the main application (this is entirely up to the OS).

So to clarify even further, you don’t program directly for a specific core, you just open a thread which will be allocated somewhere on either the core on which the program is running, or on a new core. If I fire off 6 threads in my application, and it’s running on a quad-core, it is very likely that I’ll be using all cores. If I run the same program on a dual-core, it will most likely run on both cores, and so on.

The main advantage in multi-threading on PC, still lies in the enhanced multi-tasking capabilities though, especially when we’re starting to talk about 12 core CPU’s. But either way, a program is either multi-threaded, or it’s not. A well-written application will utilize the cores you have available to you.

This entry was posted by cmv on May 20, 2008 at 9:47am. It is filed under Development, General. You can follow any comments to this entry through the RSS 2.0 feed.

Feel free to read the comments, or leave one of your own!

Also, if you're feeling social, you can Digg this, add it to del.icio.us, add it to Technorati, or add it to Newsvine!

comments are closed.