1 / 12

SMP Basics

SMP Basics. KeyStone Training Multicore Applications Literature Number: SPRPxxx . Questions. What is SMP, what are its advantages How threads are created, how do they share memories. Definition of SMP

thora
Download Presentation

SMP Basics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SMP Basics KeyStone Training Multicore Applications Literature Number: SPRPxxx

  2. Questions What is SMP, what are its advantages How threads are created, how do they share memories

  3. Definition of SMP (Symmetric MultiProcessing) A multiprocessing architecture in which multiple CPUs, residing in one cabinet, share the same memory. SMP systems provide scalability. As business increases, additional CPUs can be added to absorb the increased transaction volume.SMP systems range from two to as many as 32 or more processors. However, if one CPU fails, the entire SMP system is down. Clusters of two or more SMP systems can be used to provide high availability (fault resilience). If one SMP system fails, the others continue to operate. Definition

  4. A Pool of ResourcesOne of the CPUs boots the system and loads the SMP operating system, which brings the other CPUs online. There is only one instance of the operating system and one instance of the application in memory. The operating system uses the CPUs as a pool of processing resources, all executing simultaneously, either processing data or in an idle loop waiting to do something.Whatever Can Be OverlappedSMP speeds up the processes that can be overlapped such as running multiple applications simultaneously. If an application is multithreaded, which allows for concurrent operations within the application itself, then SMP can improve the performance of that single application. SMP work

  5. SMP high points • A single operating system • An application can be distributed between multiple cores • Memories can be global to all threads or local to each thread • Pthreads provide the parallelism

  6. A process is created by the operating system to run an application. Starting a process requires a great amount of overhead A process might have multiple procedures each one is somewhat independent from other procedures. A system that can schedule these procedures in an efficient way is multi-thread system A thread is defined as an independent stream of instructions that can be scheduled to run as such by the operating system and requires much less overhead than a process POSIX threads (pthreads) is an IEEE standard that defines portable (between different hardware) threads Threads

  7. Pthreads are defined as a set of C language programming types and procedure calls, implemented with a pthread.h header/include file and a thread library In terms of performance cost, pthreads require much less resources to be created and managed All threads within a process share the same address space. Inter-thread communication is more efficient and easier than inter-process communication. Pthreads

  8. Several common models for threaded programs exist: • Master/slaves: a single thread, the master assigns work to other threads, the slaves. Typically, the master handles all input and parcels out work to the other tasks. At least two forms of the master/slaves model are common: static slaves pool and dynamic slaves pool. • Pipeline: a task is broken into a series of sub-operations, each of which is handled in series, but concurrently, by a different thread. An automobile assembly line best describes this model. • Peer: similar to the master/slave model, but after the main thread creates other threads, it participates in the work. Parallel pthreads

  9. All threads have access to the same global, shared memory • Threads also have their own private data • Programmers are responsible for synchronizing access (protecting) globally shared data. Memory Model

  10. Mutex is an abbreviation for "mutual exclusion" A mutex variable is a "lock" (a semaphore), protecting access to a shared data resource to prevent “race” conditions Using MUTEX ensures that when a thread lock a mutex variable, no other thread can access the same variable until the mutex is released Memory protection MUTEX

  11. Condition variables behave like flags, they enable synchronization between threads based on variable value but without the needs to explicitly pull the flag value The thread gives resources to other threads until the condition variable is ready A condition variable is always used in conjunction with a mutex lock. Condition Variables

  12. SMP demo Part of the release at MCSDK_3_15\mcsdk_linux_3_00_03_15\example-applications\smp_test Need to add    #include <time.h>  #include <linux/sched.h>

More Related