Dreaded concurrency

by Chris Adamson

One of the surprising things about the multi-processor era is how poorly some applications handle it.


7 Comments

anjan bacchu
2006-09-18 13:09:22
hi there,


almost all desktop app. developers should now be getting dual core or dual processor boxes to test. At the least, testers should get those. Getting testers nice stuff will
a) test for concurrency
b) make it easy for testers to automate stuff while at the same time test those use cases which are currently not automated.


my 2 cents.


BR,
~A

Trevor
2006-09-18 14:48:45
If I understand you correctly, you're suggesting that there's application code (in Shiira and other apps) that looks something like this:


if (dualProcessor) {
// Do something
}
else {
// Do something different
}


But this is not how applications are written. When concurrency is needed, the app simply spawns threads and lets the OS handle the scheduling. The number of processors is normally transparent at the application level.


Now, it may indeed be true that Shiira has a concurrency bug (e.g., a race condition), but concurrency bugs appear on single processor systems, too. So, if an application is crashing on two processors but not one, I would blame the OS, not the app.

Dustin
2006-09-18 15:04:09
Um... Java desktop developers mostly move stuff off of the event thread, to avoid the GUI hanging, and then have it call back when done (at least for any task that won't be instantaneous). Witness the SwingWorker class for doing exactly that.
Jamie
2006-09-18 15:35:25
How do I get access to the processor preferenes pane on a MacBook?
Chris Adamson
2006-09-18 15:51:59

Now, it may indeed be true that Shiira has a concurrency bug (e.g., a race condition), but concurrency bugs appear on single processor systems, too. So, if an application is crashing on two processors but not one, I would blame the OS, not the app.


Interesting take on this from an old Dr. Dobbs article on concurrency:

What usually doesn't get caught in testing, however, except in shops that understand why and how to do real stress testing, is those latent concurrency bugs that surface only on true multiprocessor systems, where the threads aren't just being switched around on a single processor but where they really do execute truly simultaneously and thus expose new classes of errors. This is the next jolt for people who thought that surely now they know how to write concurrent code...
Jonathan Dodds
2006-09-18 16:19:01
Trevor:
You do not understand threads correctly. An application that uses multiple threads can very easily have bugs that only manifest on a multi-processor system. It has nothing to do with the OS.


On a single core uni-processor system only one thread can actually be executing at a given point in time. But true concurrency can happen on systems with two or more cores or processors.


Jamie:
Download and install Apple's CHUD developer tools.
http://developer.apple.com/tools/download/

Sengan
2007-01-04 13:05:53
I think it's the same bug I just debugged in my tool Find It! Keep It!, a webbrowser that lets you save pages to a database by pressing "KEEP IT", and lets you search for them later by tag or content. I've explained it on my blog and am trying to contact Shiira's author so that he can fix it in Shiira.