Continuing on the information presented in Part 1: The Symmetric Multi Processor (SMP) scaling problem and Part 2: The Performance Solution as presented by Pyramid Technology, my comments were addressed at the kernel. But what about user processes? Do they also need to use locking?
The answer is yes, if multiple processes share the same physical memory. This can occur with Shared Memory. User space proccesses use Shared Memory so that proccesses can easily and quickly share data. Shared Memory is the fastest Inter Process Communication(IPC) mechanism that can be employed. But it does have a cost (alas nothing is free): lack of synchronization.
If a single process is writing to shared memory, and a single process is reading the same shared memory, then locking is not needed.
If a single process is writing to shared memory, and multiple processes are reading the shared memory, then locking may or may not be required. If the shared memory is used as a resource allocator, then locks will be required. On the other hand, if the shared memory is used to post events, then locks might not be required.
Multiple Processes, Locking Required
If SMP multiple processes are writing to shared memory, then locking will be required.
User space Shared Memory is thus like the kernel. Each user process can be thought of as a seperate kernel running on different cpu. Multiple instances of a user process can run on a single cpu. If they use Shared Memory, they will then all use the same physical memory, just like the kernel. It turns out that using user processes in this manner is a great way to simulate a kernel SMP environment.
A true SMP system requires hardware memory support, called cache coherency. A cache coheriancy problem occurs when a cpu writes to physical memory and does not update or invalidate the caches on the other cpus in the system.
Next up I’ll delve more into locks.