SlideShare une entreprise Scribd logo
1  sur  89
It's All About
                   Processes Communicating

                                         Russel Winder
                                       email: russel@winder.org.uk
                                      xmpp: russel@winder.org.uk
                                         twitter: russel_winder




Copyright © 2011–2012 Russel Winder                                  1
Aims, Goals and Objects
     ●   Show that shared memory multi-threading should
         return to being an operating systems development
         technique and not continue to be pushed as an
         applications programming technique.
     ●   Show that…




Copyright © 2011–2012 Russel Winder                         2
…people should tremble in fear

                                  at the prospect of using


                          Shared-memory
                         multithreading.

Copyright © 2011–2012 Russel Winder                          3
Structure


                                      A beginning.

                                       A middle.

                                        An end.

Copyright © 2011–2012 Russel Winder                  4
Protocol
     ●   Questions or short comments during the session are
         entirely in order.
     ●   Let me know you have an interjection by raising
         your hand, and when I come to an appropriate
         pause, I'll pass you the token.

                                      Questions, answers, comments, etc. appearing
                                      to get too long as interjections may get stacked
                                      to be unstacked at a break.


Copyright © 2011–2012 Russel Winder                                                      5
Interstitial Advertisement




Copyright © 2011–2012 Russel Winder                  6
A Beginning




Copyright © 2011–2012 Russel Winder                 7
It is no longer contentious that
                         The Multicore Revolution
                             is well underway.




Copyright © 2011–2012 Russel Winder                     8
Quad core laptops and phones.

                    Eight and twelve core workstations.

                         Servers with “zillions” of cores.




Copyright © 2011–2012 Russel Winder                          9
Parallel hardware is the norm.




Copyright © 2011–2012 Russel Winder                    10
Software technology is now lagging
                 hardware technology by decades.




Copyright © 2011–2012 Russel Winder                  11
Operating systems manage cores
                            with kernel threads.

         Operating systems are fundamentally shared
              memory multi-threaded systems.

            Operating systems rightly use all the lock,
             semaphore, monitor, etc. technologies.



Copyright © 2011–2012 Russel Winder                       12
Computationally intensive systems or
             subsystems definitely have to be parallel.

                  Other systems likely use concurrency
                          but not parallelism.




Copyright © 2011–2012 Russel Winder                       13
Concurrency


                               Execution as co-routines:

            Sequences of code give up the execution
                to pass it to another coroutine.




Copyright © 2011–2012 Russel Winder                        14
More Concurrency


            Concurrency is a technique founded in a
                uniprocessor view of the world.

                            Time-division multiplexing.




Copyright © 2011–2012 Russel Winder                       15
Parallelism



                    Having multiple executions active
                           at the same time.




Copyright © 2011–2012 Russel Winder                     16
Concurrency is a tool for structuring execution where a
      single processor is used by multiple computations.


      Parallelism is about making a computation complete
                faster than using a single processor.




Copyright © 2011–2012 Russel Winder                           17
Copyright © 2011–2012 Russel Winder   18
Copyright © 2011–2012 Russel Winder   19
Copyright © 2011–2012 Russel Winder   20
Copyright © 2011–2012 Russel Winder   21
Copyright © 2011–2012 Russel Winder   22
Copyright © 2011–2012 Russel Winder   23
Copyright © 2011–2012 Russel Winder   24
Squirrel behaviour emulates
                      synchronized software behaviour.




Copyright © 2011–2012 Russel Winder                      25
Thanks to Paul King…


                               Who uses synchronized?




Copyright © 2011–2012 Russel Winder                          26
Thanks to Paul King…


                                      You did it wrong.




Copyright © 2011–2012 Russel Winder                          27
Small addition by me…


                                      Who uses lock objects?




Copyright © 2011–2012 Russel Winder                            28
Small addition by me…


                            You definitely did it wrong.




Copyright © 2011–2012 Russel Winder                        29
Locks deny parallelism.




Copyright © 2011–2012 Russel Winder                      30
The whole purpose of a lock is to
                            prevent parallelism.




Copyright © 2011–2012 Russel Winder                       31
Parallelism is performance improvement.


    Performance improvement requires parallelism.




Copyright © 2011–2012 Russel Winder                   32
Locks deny performance improvement.




Copyright © 2011–2012 Russel Winder                  33
Locks are needed only if
                           there is mutable shared state.




Copyright © 2011–2012 Russel Winder                         34
Avoid mutable shared state.




Copyright © 2011–2012 Russel Winder                    35
Use processes and message passing.




Copyright © 2011–2012 Russel Winder                     36
It's all easier if processes
                                    are single threaded.




Copyright © 2011–2012 Russel Winder                             37
…but how…




Copyright © 2011–2012 Russel Winder               38
Use appropriate architectural models.




Copyright © 2011–2012 Russel Winder                      39
A Middle




Copyright © 2011–2012 Russel Winder              40
It's all about controlling
                   concurrency and parallelism
             with tools that programmers find usable.




Copyright © 2011–2012 Russel Winder                     41
Shared memory multi-threading is
                      an operating system technique.




Copyright © 2011–2012 Russel Winder                     42
Applications and tools programmers
                    need computational models with
                       integrated synchronization.




Copyright © 2011–2012 Russel Winder                     43
Dataflow
                                            Operators connected by
    Actors                                  channels with activity
    Independent processes                   triggered by arrival of
    communicating via                       data on the channels.
    asynchronous exchange
    of messages



                                      CSP
                                      Sequential processes
                                      connected by channels
                                      using synchronous message
                                      exchange (rendezvous).
Copyright © 2011–2012 Russel Winder                                   44
Actors
    Independent processes
    communicating via
    asynchronous exchange
    of messages




Copyright © 2011–2012 Russel Winder   45
Dataflow
                                      Operators connected by
                                      channels with activity
                                      triggered by arrival of
                                      data on the channels.




Copyright © 2011–2012 Russel Winder                             46
CSP
                                      Sequential processes
                                      connected by channels
                                      using synchronous message
                                      exchange (rendezvous).
Copyright © 2011–2012 Russel Winder                               47
Need examples.




Copyright © 2011–2012 Russel Winder                    48

Copyright © 2011–2012 Russel Winder       49
What is the Value of            ?

                                  Easy, it's known exactly.

                                           It's .

                                         Obviously.



Copyright © 2011–2012 Russel Winder                            50
It's simples
                                               Александр Орлов   2009




Copyright © 2011–2012 Russel Winder                                     51
Approximating 
     ●   What is it's value represented as a floating point
         number?
          ●   We can only obtain an approximation.
          ●   A plethora of possible algorithms to choose from, a
              popular one is to employ the following integral
              equation.


                                                  1  1
                                                 =∫0       dx
                                               4     1x 2




Copyright © 2011–2012 Russel Winder                                 52
One Possible Algorithm
     ●   Use quadrature to estimate the value of the integral
         – which is the area under the curve.
                                        4 n          1
                                      = ∑i=1
                                        n           i−0.5 2
   Embarrassingly                               1      
   parallel.                                           n


                                                     With n = 3 not much to do,
                                                     but potentially lots of error.
                                                     Use n = 107 or n = 109?



Copyright © 2011–2012 Russel Winder                                                   53
Because addition is commutative and
                   associative, expression can be
               decomposed into sums of partial sums.




Copyright © 2011–2012 Russel Winder                    54
a+b+c+d+e+f

                                           =

                         (a+b)+(c+d)+(e+f)




Copyright © 2011–2012 Russel Winder                 55
Scatter – Gather




                                      map         reduce
Copyright © 2011–2012 Russel Winder                        56
Code!



Copyright © 2011–2012 Russel Winder           57
If you want the code, clone the Git repository:

      http://www.russel.org.uk/Git/Pi_Quadrature.git




Copyright © 2011–2012 Russel Winder                      58
Or if you just want to browse:

                        http://www.russel.org.uk/gitweb




Copyright © 2011–2012 Russel Winder                         59
Need another example.




Copyright © 2011–2012 Russel Winder                 60
The Sleeping Barber Problem




Copyright © 2011–2012 Russel Winder        61
The Sleeping Barber Problem
     ●   The barber's shop has a          ●   If the barber is cutting, a new
         single cutting chair and a row       customer checks to see if
         of waiting seats.                    there is a free waiting seat.
     ●   The barber sleeps in the             ●   If there is join the queue
         cutting chair unless trimming            to be trimmed.
         a customer.                          ●   If there isn't leave
     ●   Customers arrive at the shop             disgruntled.
         at intervals.
     ●   If the barber is asleep, the
         customer wakes the barber                 Problem originally due
         takes the cutting chair and               to Edsgar Dijkstra.
         gets a trim.
Copyright © 2011–2012 Russel Winder                                             62
The cutting chair.

      The waiting chairs




                                          The barber's shop.

  A new customer enters the shop,
  check to see if they can go straight
  to the cutting chair, if not can they
  take a waiting chair, if not leave.

Copyright © 2011–2012 Russel Winder                                 63
Wikipedia article presents the classic operating
      systems approach using locks and semaphores.

           http://en.wikipedia.org/wiki/Sleeping_barber_problem




Copyright © 2011–2012 Russel Winder                               64
More code!



Copyright © 2011–2012 Russel Winder                65
If you want the code, clone the Git repository:

     http://www.russel.org.uk/Git/SleepingBarber.git




Copyright © 2011–2012 Russel Winder                      66
Or if you just want to browse:

                        http://www.russel.org.uk/gitweb




Copyright © 2011–2012 Russel Winder                         67
An End




Copyright © 2011–2012 Russel Winder            68
Multicore and multiprocessor are now
                the norm, not the exception.




Copyright © 2011–2012 Russel Winder                69
Parallelism only matters if
             computational performance matters.




Copyright © 2011–2012 Russel Winder               70
Unstructured synchronization
                           of concurrent systems
                        is not a feasible approach.




Copyright © 2011–2012 Russel Winder                   71
Actors, CSP and Dataflow
                                 are the future of
                              applications structure.




Copyright © 2011–2012 Russel Winder                     72
Passing messages between
                        processes is the way forward.




Copyright © 2011–2012 Russel Winder                     73
Shared memory concurrency
                      is a dead end for applications.




Copyright © 2011–2012 Russel Winder                     74
Copyright © 2011–2012 Russel Winder   75
Copyright © 2011–2012 Russel Winder   76
Copyright © 2011–2012 Russel Winder   77
Copyright © 2011–2012 Russel Winder   78
Copyright © 2011–2012 Russel Winder   79
Copyright © 2011–2012 Russel Winder   80
Squirrels deny parallelism.




Copyright © 2011–2012 Russel Winder                      81
Squirrels deny performance enhancement.




Copyright © 2011–2012 Russel Winder            82
Don't be a squirrel.




Copyright © 2011–2012 Russel Winder                          83
Do not use explicit locking algorithms.




Copyright © 2011–2012 Russel Winder                       84
Use computational architectures that promote
            parallelism and hence performance
                       improvement:

                                           Actors
                                         Dataflow
                                            CSP
                                      Data Parallelism



Copyright © 2011–2012 Russel Winder                      85
Use



                                       Go on, you know you want to…
Copyright © 2011–2012 Russel Winder                                   86
Surreptitious Advertisement




Copyright © 2011–2012 Russel Winder                87
The End




Copyright © 2011–2012 Russel Winder             88
It's All About
                   Processes Communicating

                                         Russel Winder
                                       email: russel@winder.org.uk
                                      xmpp: russel@winder.org.uk
                                         twitter: russel_winder




Copyright © 2011–2012 Russel Winder                                  89

Contenu connexe

Similaire à It's all about processes communicating - Russel Winder

Just Keep Sending The Messages
Just Keep Sending The MessagesJust Keep Sending The Messages
Just Keep Sending The Messages
Russel Winder
 
Structured development in BMC Remedy AR System
Structured development in BMC Remedy AR SystemStructured development in BMC Remedy AR System
Structured development in BMC Remedy AR System
gramlin42
 

Similaire à It's all about processes communicating - Russel Winder (20)

ACCU 2012: Go, D, C++ and The Multicore Revolution
ACCU 2012:  Go, D, C++ and The Multicore RevolutionACCU 2012:  Go, D, C++ and The Multicore Revolution
ACCU 2012: Go, D, C++ and The Multicore Revolution
 
Just Keep Passing The Messages
Just Keep Passing The MessagesJust Keep Passing The Messages
Just Keep Passing The Messages
 
Just Keep Sending The Messages
Just Keep Sending The MessagesJust Keep Sending The Messages
Just Keep Sending The Messages
 
Just Keep Sending The Messages
Just Keep Sending The MessagesJust Keep Sending The Messages
Just Keep Sending The Messages
 
GPars Workshop
GPars WorkshopGPars Workshop
GPars Workshop
 
Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.
 
Why Go is an important programming language
Why Go is an important programming languageWhy Go is an important programming language
Why Go is an important programming language
 
Why Groovy When Java 8 or Scala, or…
Why Groovy When Java 8 or Scala, or…Why Groovy When Java 8 or Scala, or…
Why Groovy When Java 8 or Scala, or…
 
Dataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you needDataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you need
 
On Concurrency and Parallelism in the JVMverse
On Concurrency and Parallelism in the JVMverseOn Concurrency and Parallelism in the JVMverse
On Concurrency and Parallelism in the JVMverse
 
Closures, the next "Big Thing" in Java: Russel Winder
Closures, the next "Big Thing" in Java: Russel WinderClosures, the next "Big Thing" in Java: Russel Winder
Closures, the next "Big Thing" in Java: Russel Winder
 
Closures: The Next "Big Thing" In Java
Closures: The Next "Big Thing" In JavaClosures: The Next "Big Thing" In Java
Closures: The Next "Big Thing" In Java
 
GPars Remoting
GPars RemotingGPars Remoting
GPars Remoting
 
Fluxx-The Tested User event-011112-main presentation
Fluxx-The Tested User event-011112-main presentationFluxx-The Tested User event-011112-main presentation
Fluxx-The Tested User event-011112-main presentation
 
GPars 2014
GPars 2014GPars 2014
GPars 2014
 
The Case for Kotlin and Ceylon
The Case for Kotlin and CeylonThe Case for Kotlin and Ceylon
The Case for Kotlin and Ceylon
 
Designing a Bad A$$ Backup Target without Breaking the Bank
Designing a Bad A$$ Backup Target without Breaking the BankDesigning a Bad A$$ Backup Target without Breaking the Bank
Designing a Bad A$$ Backup Target without Breaking the Bank
 
Dataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel WinderDataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel Winder
 
Dataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel WinderDataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel Winder
 
Structured development in BMC Remedy AR System
Structured development in BMC Remedy AR SystemStructured development in BMC Remedy AR System
Structured development in BMC Remedy AR System
 

Plus de JAX London

Everything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexityEverything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexity
JAX London
 

Plus de JAX London (20)

Everything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexityEverything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexity
 
Devops with the S for Sharing - Patrick Debois
Devops with the S for Sharing - Patrick DeboisDevops with the S for Sharing - Patrick Debois
Devops with the S for Sharing - Patrick Debois
 
Busy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript AppsBusy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript Apps
 
It's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick DeboisIt's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick Debois
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael Barker
 
Worse is better, for better or for worse - Kevlin Henney
Worse is better, for better or for worse - Kevlin HenneyWorse is better, for better or for worse - Kevlin Henney
Worse is better, for better or for worse - Kevlin Henney
 
Java performance: What's the big deal? - Trisha Gee
Java performance: What's the big deal? - Trisha GeeJava performance: What's the big deal? - Trisha Gee
Java performance: What's the big deal? - Trisha Gee
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias WessendorfHTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
 
Play framework 2 : Peter Hilton
Play framework 2 : Peter HiltonPlay framework 2 : Peter Hilton
Play framework 2 : Peter Hilton
 
Complexity theory and software development : Tim Berglund
Complexity theory and software development : Tim BerglundComplexity theory and software development : Tim Berglund
Complexity theory and software development : Tim Berglund
 
Why FLOSS is a Java developer's best friend: Dave Gruber
Why FLOSS is a Java developer's best friend: Dave GruberWhy FLOSS is a Java developer's best friend: Dave Gruber
Why FLOSS is a Java developer's best friend: Dave Gruber
 
Akka in Action: Heiko Seeburger
Akka in Action: Heiko SeeburgerAkka in Action: Heiko Seeburger
Akka in Action: Heiko Seeburger
 
NoSQL Smackdown 2012 : Tim Berglund
NoSQL Smackdown 2012 : Tim BerglundNoSQL Smackdown 2012 : Tim Berglund
NoSQL Smackdown 2012 : Tim Berglund
 
Java and the machine - Martijn Verburg and Kirk Pepperdine
Java and the machine - Martijn Verburg and Kirk PepperdineJava and the machine - Martijn Verburg and Kirk Pepperdine
Java and the machine - Martijn Verburg and Kirk Pepperdine
 
Mongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsMongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdams
 
New opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian RobinsonNew opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian Robinson
 
HTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun GuptaHTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun Gupta
 
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian PloskerThe Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
 

Dernier

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
 

Dernier (20)

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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 

It's all about processes communicating - Russel Winder

  • 1. It's All About Processes Communicating Russel Winder email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: russel_winder Copyright © 2011–2012 Russel Winder 1
  • 2. Aims, Goals and Objects ● Show that shared memory multi-threading should return to being an operating systems development technique and not continue to be pushed as an applications programming technique. ● Show that… Copyright © 2011–2012 Russel Winder 2
  • 3. …people should tremble in fear at the prospect of using Shared-memory multithreading. Copyright © 2011–2012 Russel Winder 3
  • 4. Structure A beginning. A middle. An end. Copyright © 2011–2012 Russel Winder 4
  • 5. Protocol ● Questions or short comments during the session are entirely in order. ● Let me know you have an interjection by raising your hand, and when I come to an appropriate pause, I'll pass you the token. Questions, answers, comments, etc. appearing to get too long as interjections may get stacked to be unstacked at a break. Copyright © 2011–2012 Russel Winder 5
  • 6. Interstitial Advertisement Copyright © 2011–2012 Russel Winder 6
  • 7. A Beginning Copyright © 2011–2012 Russel Winder 7
  • 8. It is no longer contentious that The Multicore Revolution is well underway. Copyright © 2011–2012 Russel Winder 8
  • 9. Quad core laptops and phones. Eight and twelve core workstations. Servers with “zillions” of cores. Copyright © 2011–2012 Russel Winder 9
  • 10. Parallel hardware is the norm. Copyright © 2011–2012 Russel Winder 10
  • 11. Software technology is now lagging hardware technology by decades. Copyright © 2011–2012 Russel Winder 11
  • 12. Operating systems manage cores with kernel threads. Operating systems are fundamentally shared memory multi-threaded systems. Operating systems rightly use all the lock, semaphore, monitor, etc. technologies. Copyright © 2011–2012 Russel Winder 12
  • 13. Computationally intensive systems or subsystems definitely have to be parallel. Other systems likely use concurrency but not parallelism. Copyright © 2011–2012 Russel Winder 13
  • 14. Concurrency Execution as co-routines: Sequences of code give up the execution to pass it to another coroutine. Copyright © 2011–2012 Russel Winder 14
  • 15. More Concurrency Concurrency is a technique founded in a uniprocessor view of the world. Time-division multiplexing. Copyright © 2011–2012 Russel Winder 15
  • 16. Parallelism Having multiple executions active at the same time. Copyright © 2011–2012 Russel Winder 16
  • 17. Concurrency is a tool for structuring execution where a single processor is used by multiple computations. Parallelism is about making a computation complete faster than using a single processor. Copyright © 2011–2012 Russel Winder 17
  • 18. Copyright © 2011–2012 Russel Winder 18
  • 19. Copyright © 2011–2012 Russel Winder 19
  • 20. Copyright © 2011–2012 Russel Winder 20
  • 21. Copyright © 2011–2012 Russel Winder 21
  • 22. Copyright © 2011–2012 Russel Winder 22
  • 23. Copyright © 2011–2012 Russel Winder 23
  • 24. Copyright © 2011–2012 Russel Winder 24
  • 25. Squirrel behaviour emulates synchronized software behaviour. Copyright © 2011–2012 Russel Winder 25
  • 26. Thanks to Paul King… Who uses synchronized? Copyright © 2011–2012 Russel Winder 26
  • 27. Thanks to Paul King… You did it wrong. Copyright © 2011–2012 Russel Winder 27
  • 28. Small addition by me… Who uses lock objects? Copyright © 2011–2012 Russel Winder 28
  • 29. Small addition by me… You definitely did it wrong. Copyright © 2011–2012 Russel Winder 29
  • 30. Locks deny parallelism. Copyright © 2011–2012 Russel Winder 30
  • 31. The whole purpose of a lock is to prevent parallelism. Copyright © 2011–2012 Russel Winder 31
  • 32. Parallelism is performance improvement. Performance improvement requires parallelism. Copyright © 2011–2012 Russel Winder 32
  • 33. Locks deny performance improvement. Copyright © 2011–2012 Russel Winder 33
  • 34. Locks are needed only if there is mutable shared state. Copyright © 2011–2012 Russel Winder 34
  • 35. Avoid mutable shared state. Copyright © 2011–2012 Russel Winder 35
  • 36. Use processes and message passing. Copyright © 2011–2012 Russel Winder 36
  • 37. It's all easier if processes are single threaded. Copyright © 2011–2012 Russel Winder 37
  • 38. …but how… Copyright © 2011–2012 Russel Winder 38
  • 39. Use appropriate architectural models. Copyright © 2011–2012 Russel Winder 39
  • 40. A Middle Copyright © 2011–2012 Russel Winder 40
  • 41. It's all about controlling concurrency and parallelism with tools that programmers find usable. Copyright © 2011–2012 Russel Winder 41
  • 42. Shared memory multi-threading is an operating system technique. Copyright © 2011–2012 Russel Winder 42
  • 43. Applications and tools programmers need computational models with integrated synchronization. Copyright © 2011–2012 Russel Winder 43
  • 44. Dataflow Operators connected by Actors channels with activity Independent processes triggered by arrival of communicating via data on the channels. asynchronous exchange of messages CSP Sequential processes connected by channels using synchronous message exchange (rendezvous). Copyright © 2011–2012 Russel Winder 44
  • 45. Actors Independent processes communicating via asynchronous exchange of messages Copyright © 2011–2012 Russel Winder 45
  • 46. Dataflow Operators connected by channels with activity triggered by arrival of data on the channels. Copyright © 2011–2012 Russel Winder 46
  • 47. CSP Sequential processes connected by channels using synchronous message exchange (rendezvous). Copyright © 2011–2012 Russel Winder 47
  • 48. Need examples. Copyright © 2011–2012 Russel Winder 48
  • 49.  Copyright © 2011–2012 Russel Winder 49
  • 50. What is the Value of ? Easy, it's known exactly. It's . Obviously. Copyright © 2011–2012 Russel Winder 50
  • 51. It's simples Александр Орлов 2009 Copyright © 2011–2012 Russel Winder 51
  • 52. Approximating  ● What is it's value represented as a floating point number? ● We can only obtain an approximation. ● A plethora of possible algorithms to choose from, a popular one is to employ the following integral equation.  1 1 =∫0 dx 4 1x 2 Copyright © 2011–2012 Russel Winder 52
  • 53. One Possible Algorithm ● Use quadrature to estimate the value of the integral – which is the area under the curve. 4 n 1 = ∑i=1 n i−0.5 2 Embarrassingly 1  parallel. n With n = 3 not much to do, but potentially lots of error. Use n = 107 or n = 109? Copyright © 2011–2012 Russel Winder 53
  • 54. Because addition is commutative and associative, expression can be decomposed into sums of partial sums. Copyright © 2011–2012 Russel Winder 54
  • 55. a+b+c+d+e+f = (a+b)+(c+d)+(e+f) Copyright © 2011–2012 Russel Winder 55
  • 56. Scatter – Gather map reduce Copyright © 2011–2012 Russel Winder 56
  • 57. Code! Copyright © 2011–2012 Russel Winder 57
  • 58. If you want the code, clone the Git repository: http://www.russel.org.uk/Git/Pi_Quadrature.git Copyright © 2011–2012 Russel Winder 58
  • 59. Or if you just want to browse: http://www.russel.org.uk/gitweb Copyright © 2011–2012 Russel Winder 59
  • 60. Need another example. Copyright © 2011–2012 Russel Winder 60
  • 61. The Sleeping Barber Problem Copyright © 2011–2012 Russel Winder 61
  • 62. The Sleeping Barber Problem ● The barber's shop has a ● If the barber is cutting, a new single cutting chair and a row customer checks to see if of waiting seats. there is a free waiting seat. ● The barber sleeps in the ● If there is join the queue cutting chair unless trimming to be trimmed. a customer. ● If there isn't leave ● Customers arrive at the shop disgruntled. at intervals. ● If the barber is asleep, the customer wakes the barber Problem originally due takes the cutting chair and to Edsgar Dijkstra. gets a trim. Copyright © 2011–2012 Russel Winder 62
  • 63. The cutting chair. The waiting chairs The barber's shop. A new customer enters the shop, check to see if they can go straight to the cutting chair, if not can they take a waiting chair, if not leave. Copyright © 2011–2012 Russel Winder 63
  • 64. Wikipedia article presents the classic operating systems approach using locks and semaphores. http://en.wikipedia.org/wiki/Sleeping_barber_problem Copyright © 2011–2012 Russel Winder 64
  • 65. More code! Copyright © 2011–2012 Russel Winder 65
  • 66. If you want the code, clone the Git repository: http://www.russel.org.uk/Git/SleepingBarber.git Copyright © 2011–2012 Russel Winder 66
  • 67. Or if you just want to browse: http://www.russel.org.uk/gitweb Copyright © 2011–2012 Russel Winder 67
  • 68. An End Copyright © 2011–2012 Russel Winder 68
  • 69. Multicore and multiprocessor are now the norm, not the exception. Copyright © 2011–2012 Russel Winder 69
  • 70. Parallelism only matters if computational performance matters. Copyright © 2011–2012 Russel Winder 70
  • 71. Unstructured synchronization of concurrent systems is not a feasible approach. Copyright © 2011–2012 Russel Winder 71
  • 72. Actors, CSP and Dataflow are the future of applications structure. Copyright © 2011–2012 Russel Winder 72
  • 73. Passing messages between processes is the way forward. Copyright © 2011–2012 Russel Winder 73
  • 74. Shared memory concurrency is a dead end for applications. Copyright © 2011–2012 Russel Winder 74
  • 75. Copyright © 2011–2012 Russel Winder 75
  • 76. Copyright © 2011–2012 Russel Winder 76
  • 77. Copyright © 2011–2012 Russel Winder 77
  • 78. Copyright © 2011–2012 Russel Winder 78
  • 79. Copyright © 2011–2012 Russel Winder 79
  • 80. Copyright © 2011–2012 Russel Winder 80
  • 81. Squirrels deny parallelism. Copyright © 2011–2012 Russel Winder 81
  • 82. Squirrels deny performance enhancement. Copyright © 2011–2012 Russel Winder 82
  • 83. Don't be a squirrel. Copyright © 2011–2012 Russel Winder 83
  • 84. Do not use explicit locking algorithms. Copyright © 2011–2012 Russel Winder 84
  • 85. Use computational architectures that promote parallelism and hence performance improvement: Actors Dataflow CSP Data Parallelism Copyright © 2011–2012 Russel Winder 85
  • 86. Use Go on, you know you want to… Copyright © 2011–2012 Russel Winder 86
  • 87. Surreptitious Advertisement Copyright © 2011–2012 Russel Winder 87
  • 88. The End Copyright © 2011–2012 Russel Winder 88
  • 89. It's All About Processes Communicating Russel Winder email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: russel_winder Copyright © 2011–2012 Russel Winder 89