Originally posted by: CTho9305
It's generally not trivial - spawning threads is easy, but dividing up work intelligently to maximize performance can be difficult. Correctly using locks for shared data can get very hard too, especially if you want very fine-grained locking to minimize contention.
What I was referring to was the difference in SMP vs. uniprocessor systems from the user application perspective - there is none (perhaps thread processor affinity but that's neglible).
The sames rules of writing high quality multithreaded code apply in both cases.
That's opposed to the problems in kernel programming when more than one processor is present, especially problems with interrupt handling on multiple processors.
The other problem is that some kernels operate in a non-interruptible monolithic context (i.e. a context switch never occurs during kernel execution).
In such cases, on a uniprocessor system, the only way to interrupt the program flow (and cause possible synchronization problems) is by an interrupt request.
But what happens when you introduce another processor into the system? The kernel is no longer truely "monolithic" - the other processor might be executing the same code, even when your local processor has interrupt disabled.
It requires some adaption from kernel programmers.
Linux 2.6.x, IIRC, allows context switches in kernel mode, so some part of this problem is eliminated (there's less difference between execution on uni- and multiprocessor systems in that regard).
- All of that is written from the top of my head, I might be wrong on some aspects... Quite a while since I've written SMP-compatible driver code.