Smp basics
Download
1 / 12

SMP Basics - PowerPoint PPT Presentation


  • 150 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' SMP Basics' - thora


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Smp basics

SMP Basics

KeyStone Training

Multicore Applications

Literature Number: SPRPxxx


Questions

Questions

What is SMP, what are its advantages

How threads are created, how do they share memories


Definition

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


Smp work

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


Smp high points
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


Threads

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


Pthreads

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


Parallel pthreads

  • Several common models for threaded programs exist: types and procedure calls, implemented with a pthread.h header/include file and a thread library

    • 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


Memory model

Memory Model


Memory protection mutex

Mutex is an abbreviation for "mutual exclusion" types and procedure calls, implemented with a pthread.h header/include file and a thread library

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


Condition variables

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


Smp demo

SMP demo synchronization between threads based on variable value but without the needs to explicitly pull the flag value

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>


ad