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

Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Java
parag
 

What's hot (20)

Introduction to Apache Hive
Introduction to Apache HiveIntroduction to Apache Hive
Introduction to Apache Hive
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 
Java threads
Java threadsJava threads
Java threads
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and Concurrency
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Threads in python
Threads in pythonThreads in python
Threads in python
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Java
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Python Modules
Python ModulesPython Modules
Python Modules
 
Perceptron & Neural Networks
Perceptron & Neural NetworksPerceptron & Neural Networks
Perceptron & Neural Networks
 
java-thread
java-threadjava-thread
java-thread
 
NVIDIA CUDA
NVIDIA CUDANVIDIA CUDA
NVIDIA CUDA
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
Java thread life cycle
Java thread life cycleJava thread life cycle
Java thread life cycle
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Java Threads
Java ThreadsJava Threads
Java Threads
 
Thread model in java
Thread model in javaThread model in java
Thread model in java
 

Viewers also liked (6)

How to Use Multi-thread & Multi-process in Python
How to Use Multi-thread & Multi-process in PythonHow to Use Multi-thread & Multi-process in Python
How to Use Multi-thread & Multi-process in Python
 
Multiprocessing with python
Multiprocessing with pythonMultiprocessing with python
Multiprocessing with python
 
Parallel Programming
Parallel ProgrammingParallel Programming
Parallel Programming
 
Object-oriented Programming in Python
Object-oriented Programming in PythonObject-oriented Programming in Python
Object-oriented Programming in Python
 
Memory Management In Python The Basics
Memory Management In Python The BasicsMemory Management In Python The Basics
Memory Management In Python The Basics
 
An Introduction to Python Concurrency
An Introduction to Python ConcurrencyAn Introduction to Python Concurrency
An Introduction to Python Concurrency
 

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

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

Parallel programming using python