SlideShare a Scribd company logo
1 of 20
Download to read offline
Introduction to
Parallel Programming
using Python
Presented by: Samah Gad
July 11, 2013
Friday, July 12, 13
Road Map
Motivation
Forking Processes
Threads
Interprocess Communication - Overview
The multiprocessing Module - Overview
Friday, July 12, 13
Motivation
Problem:
Most computers spend a lot of time
doing nothing.
Majority of the modern CPU’s capacity
is often spent in an idle state.
Friday, July 12, 13
Motivation -Cont.
Solution:
Running more than one program at a
time.
Dividing the CPU attention among a
set of tasks.
Parallel Processing, Multiprocessing,
or Multitasking.
Friday, July 12, 13
Parallel Processing in
Python
Two main ways to run tasks:
Process forks
Spawned threads
Python built-in tools like: os.fork, threading,
queue, and multiprocessing.
Third Party domains offers more advanced
tools.
Friday, July 12, 13
Forking Processes
Traditional ways to structure parallel
tasks.
Straight forward way to start an
independent program.
What is forking?
Copying programs.
Python Module - os.fork
Friday, July 12, 13
Example 1
Friday, July 12, 13
Example 2
Friday, July 12, 13
Threads
Another way to start activities
running at the same time.
Lightweight processes
Run within the same single process.
Friday, July 12, 13
Threads - Advantages:
Performance
Simplicity
Shared global memory
Portability
Friday, July 12, 13
Python Modules
Python Modules:
_thread module
threading modules
Both modules provide tools for
synchronizing access to shared objects
with locks.
Friday, July 12, 13
The _thread Module
Start new independent threads of
execution within a process.
Doesn't support OOP
Platform independent module.
Friday, July 12, 13
Example 3
Friday, July 12, 13
Example 4
Friday, July 12, 13
Synchronizing access to
shared objects and names
What is problem?
Objects and namespaces in a process
that span the life of threads are
shared by all spawned threads.
Solution:
Threads automatically come with a
cross-task communications
Friday, July 12, 13
Example 5
Friday, July 12, 13
Threading Module
Internally uses the _thread module to
implement objects that represent
threads and common synchronization
tools.
Manage threads with high-level class-
based objects.
Friday, July 12, 13
Example 6
Friday, July 12, 13
Interprocess
Communication - Overview
Other solutions don’t support cross-
program communication
Sockets, Pipes, and Signals
Enable performing Inter-Process
Communication (IPC)
Friday, July 12, 13
The multiprocessing
Module - Overview
Provide the best of processes and threads.
Platform independent.
Uses processes instead of threads.
Provide synchronizations tools.
Leverage the capacity of multiple
processors.
Friday, July 12, 13

More Related Content

What's hot

Subnetting Presentation
Subnetting PresentationSubnetting Presentation
Subnetting Presentation
Touhidul Fahim
 
Cloud computing and grid computing 360 degree compared
Cloud computing and grid computing 360 degree comparedCloud computing and grid computing 360 degree compared
Cloud computing and grid computing 360 degree compared
Md. Hasibur Rashid
 
Distributed computing
Distributed computingDistributed computing
Distributed computing
shivli0769
 

What's hot (20)

Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Chapter 20: Internet Protocol
Chapter 20: Internet ProtocolChapter 20: Internet Protocol
Chapter 20: Internet Protocol
 
1.prallelism
1.prallelism1.prallelism
1.prallelism
 
Tcpdump
TcpdumpTcpdump
Tcpdump
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
 
TCP and UDP
TCP and UDP TCP and UDP
TCP and UDP
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
Multiple processor (ppt 2010)
Multiple processor (ppt 2010)Multiple processor (ppt 2010)
Multiple processor (ppt 2010)
 
DDoS Attack Detection & Mitigation in SDN
DDoS Attack Detection & Mitigation in SDNDDoS Attack Detection & Mitigation in SDN
DDoS Attack Detection & Mitigation in SDN
 
Subnetting Presentation
Subnetting PresentationSubnetting Presentation
Subnetting Presentation
 
Cloud computing and grid computing 360 degree compared
Cloud computing and grid computing 360 degree comparedCloud computing and grid computing 360 degree compared
Cloud computing and grid computing 360 degree compared
 
Introduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed ComputingIntroduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed Computing
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
 
Distributed computing
Distributed computingDistributed computing
Distributed computing
 
Parallel computing
Parallel computingParallel computing
Parallel computing
 
message passing vs shared memory
message passing vs shared memorymessage passing vs shared memory
message passing vs shared memory
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
 
Computer Architecture for Parallel Processing
Computer Architecture for Parallel ProcessingComputer Architecture for Parallel Processing
Computer Architecture for Parallel Processing
 
CS9222 Advanced Operating System
CS9222 Advanced Operating SystemCS9222 Advanced Operating System
CS9222 Advanced Operating System
 

Similar to Parallel programming using python

Parallel programming using python
Parallel programming using python Parallel programming using python
Parallel programming using python
Samah Gad
 
Jonathan bright - collecting social media data with the python programming la...
Jonathan bright - collecting social media data with the python programming la...Jonathan bright - collecting social media data with the python programming la...
Jonathan bright - collecting social media data with the python programming la...
oiisdp
 
Contributing to Drupal
Contributing to DrupalContributing to Drupal
Contributing to Drupal
Chris Skene
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
Raghu nath
 

Similar to Parallel programming using python (20)

Parallel programming using python
Parallel programming using python Parallel programming using python
Parallel programming using python
 
Jonathan bright - collecting social media data with the python programming la...
Jonathan bright - collecting social media data with the python programming la...Jonathan bright - collecting social media data with the python programming la...
Jonathan bright - collecting social media data with the python programming la...
 
Dlsecyx pgroammr (Dyslexic Programmer - cool stuff for scaling)
Dlsecyx pgroammr (Dyslexic Programmer - cool stuff for scaling)Dlsecyx pgroammr (Dyslexic Programmer - cool stuff for scaling)
Dlsecyx pgroammr (Dyslexic Programmer - cool stuff for scaling)
 
Dig1108 c lesson1
Dig1108 c lesson1Dig1108 c lesson1
Dig1108 c lesson1
 
Multithreading by rj
Multithreading by rjMultithreading by rj
Multithreading by rj
 
High Performance NodeJS
High Performance NodeJSHigh Performance NodeJS
High Performance NodeJS
 
Paralle Programming in Python
Paralle Programming in PythonParalle Programming in Python
Paralle Programming in Python
 
Scaling Puppet Usage to a Global Organization
Scaling Puppet Usage to a Global OrganizationScaling Puppet Usage to a Global Organization
Scaling Puppet Usage to a Global Organization
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101
 
Reverse engineering and instrumentation of android apps
Reverse engineering and instrumentation of android appsReverse engineering and instrumentation of android apps
Reverse engineering and instrumentation of android apps
 
OOP_chapter _1.pptx
OOP_chapter _1.pptxOOP_chapter _1.pptx
OOP_chapter _1.pptx
 
Fast and Reproducible Deep Learning
Fast and Reproducible Deep LearningFast and Reproducible Deep Learning
Fast and Reproducible Deep Learning
 
concurrency
concurrencyconcurrency
concurrency
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
 
Web meeting tools in the "SUNY Nebula"
Web meeting tools in the "SUNY Nebula"Web meeting tools in the "SUNY Nebula"
Web meeting tools in the "SUNY Nebula"
 
Contributing to Drupal
Contributing to DrupalContributing to Drupal
Contributing to Drupal
 
INTRODUCTION TO JAVA
INTRODUCTION TO JAVAINTRODUCTION TO JAVA
INTRODUCTION TO JAVA
 
5212303961620480 1585670953 joanna_stachera_proposal_g_soc2020
5212303961620480 1585670953 joanna_stachera_proposal_g_soc20205212303961620480 1585670953 joanna_stachera_proposal_g_soc2020
5212303961620480 1585670953 joanna_stachera_proposal_g_soc2020
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Parallel programming using python