Before multicore processors became mainstream, there was a popular model called Symmetric Multiprocessing (SMP). This model was in vogue in 1990's.
An SMP architecture is one where two or more IDENTICAL processors are connected through a SHARED common memory. Each processor has equal access to the shared memory (they have same latency to the memory). This is differnet from a Non-Uniform Memory Access (NUMA) architecture, where each processor has its own local memory but also has access to shared memory with a different access latency.
In 1990's engineers used to build loosely coupled multiprocessor systems, which were basically stand alone computers, but connected through a backplane like ethernet. They were not efficient and also costly to setup.
With the advent of multicore processors, we have multiple cores in a physical package, all accessing the shared memory. The programming model is almost same as the SMP programming.
If we have to take advantage of multiple cores in a SMP model, we need to split the applications to threads, which run independently on different cores, accessing same memory, but with access protection to critical data.
Linux has been in the forefront of supporting multiprocessing from the SMP days. It started with Linux 2.0, where it supported SMP with what is known as big kernel lock (BKL).
Suppose we have 4 threads in an application and we have a 4 core processor. In ideal situation, we will have the one thread running on each core. Suppose, one of them makes a system call, which traps to the kernel. In the BKL model, the kernel used to have a lock at the entry and released it when it exited kernel. This way, Linux 2.0 supported SMP/multicore systems, which allowed only one processor to be running kernel code at any given time. It was a quick and dirty but decent start to support SMP and multicore systems.
Making the kernel safe for concurrent access from multiple cores was a daunting multi-year effort; In 2.6, linux has managed it and now kernel has fine grain locks. Recent version 2.6.37 has gotten rid of BKLs completely.
Using a linux 2.6.x system allows a multithreaded application to take advantage of the multicore systems completely and provides scalability. The effect of this scaling is easily seen in servers, which run Linux 2.6.x where a thread is typically spawned for each client request and they are run on a free core.
文章评论(0条评论)
登录后参与讨论