Symmetric Multiprocessing Part 1

    int num = 0;
    for (int i = 1; i <= 1000; i++)
    {
        num += i;
    }

This for loop is what they don’t call multiprocessing , this for loop is an example of how most of us write programs, we often specify our algorithms as a sequence of instructions, and then let our processor executes this instructions in sequence one at time. Each instruction is executed in a sequence of operations (Fetch, Decode, Execute) which is called the instruction cycle, Taking a deep look at this cycle we see that each of the (Fetch, Decode, Execute) phase is achieved by a set of micro-operations which are no more than multiple control signals generated at the same time in concurrent manner.

Nowadays, computer hardware prices has dropped, and computer designers strive more and more for parallelism, usually to improve performance, We examine here symmetric multiprocessing (SMP), a very popular approach to parallelism by replicating processors.


Before we start our discussing about SMP, lets first know what type of parallel processors SMP fits. here are a categorization of the most common parallel processor architectures:

  1. Single instruction single data (SISD) stream:

    • A single processor executes a single instruction stream to operate on data stored in a single memory, this the view of most of use to our computers.
    • The above for loop is an example of a single instruction stream, and a single data.
  1. Single instruction multiple data (SIMD) stream:
    • A single machine instruction controls the simultaneous execution of a number of processors, where each processor has an associated data memory, so that each instruction is executed on a different set of data by the different processors, Vectors and array processors are example of SIMD.
    • SIMD instructions are widely used to process 3D graphics and cryptography, although modern graphic cards with embedded SIMD have largely taken over this task from the CPU, an example is CUDA, a parallel computing architecture developed by NVIDIA.
    • Intel`s MMX and AMD`s 3DNow! are examples of SIMD.
    • An application that may take advantage of SIMD is one where the same value is being added (or subtracted) to a large number of data points, a common operation in many multimedia applications. One example would be changing the brightness of an image. Each pixel of an image consists of three values for the brightness of the red, green and blue portions of the color. To change the brightness, the R G and B values are read from memory, a value is added (or subtracted) from them, and the resulting values are written back out to memory.
    • Check this SIMD programming with Playstation 3.
  2. Multiple instruction single data (MISD) stream:
    • A sequence of data is transmitted to a set of processors, each of which executes a different instruction sequence.
    • Pipeline architectures belong to this type.
  3. Multiple instruction multiple data (MIMD) stream:
    • A set of processors simultaneously execute different instruction sequence on different data sets.
    • Machines using MIMD have a number of processors that function asynchronously and independently
    • MIMD architectures may be used in a number of application areas such as computer-aided design/computer-aided manufacturing, simulation, modeling.
    • MIMD organization can be further divided by means of how processors communicate with each other.
      • Each processor has a dedicated memory, then it self-contained, and it acts independent of the other processors. Communication among those computer processors are either via fixed paths or networks, such systems are called cluster.
      • If the processors share a common memory, then each processor access date and code in a shared memory, and they communicate with each other via the main memory.
    • Shared memory multiprocessors can be further classified into 2 categories based on how processes are assigned to processors:
      1. Master/Slave architecture:
        • The OS kernel always run on a particular processor. The other processors may only execute user processes and may be OS utilities.
        • Master processor is responsible for scheduling processes or threads, If a slave processor needs a service (I/O request), then it should send a request to the master and wait for the service to be performed.
      2. Symmetric Multiprocessor architecture:
        • The kernel can execute on any processor, and each processor does self-scheduling from the pool of available threads, allowing portions of the kernel to execute in parallel.
        • SMP complicates the OS, because it must ensure that two processors don’t choose the same process, and this requires the OS to apply synchronization techniques among processors.

image

To be continued …


References

Operating Systems: Internals and Design Principles (6th Edition), William Stallings