Print

Code Watch: Three building blocks for parallel systems



Larry O'Brien
Email
December 15, 2011 —  (Page 1 of 3)
While there is no solution to concurrency in sight, there are three programming abstractions, which have become near-universal building blocks for highly parallel systems: data-parallel loops, Actors, and Futures.

Data-parallel loops are the simplest parallelism that could possibly work. Essentially, they just farm out each loop iteration to a separate thread. This is an expensive operation compared to looping, but if the loop's body is a performance bottleneck, the performance gained by distributing it across cores or processors can be close to linear (there will always be a little overhead). It's important that each loop be independent, which may entail some refactoring of loop-carried dependencies, but, in general, there's nothing not to like about this approach. Data-parallel looping constructs are universally available in mainstream languages.

Actors are objects that, conceptually, run in their own thread (conceptually because system-level threads are typically rather expensive to create and limited in availability, so Actors are usually implemented on top of a fairly complex thread pool provided by the language runtime). A normal Object embodies the only functions that can access that object's non-public data, and that makes reasoning about the data's meaning and validity easier than otherwise. An Actor embodies the only thread that can access that object's non-public members, with similar benefits to reasoning about concurrency. This is so logical that when I first learned OOP, I was surprised to find out it wasn't the norm.

The Actor has a function that loops, reacting to lightweight messages and posting them to the outside world. This is almost always referred to as a mailbox metaphor, but I like to call it a WinMain, just to provoke a reaction (unfortunately, it's getting to the point where not everyone gets the reference). Deep thinkers argue about subtleties of the mailbox (particularly, whether its guarantees about message delivery and ordering are wise or foolish), but if you've programmed Windows in C (or a similar architecture), you know the pattern. You also know how it can break down, with hard-to-debug situations where the troublesome program state is encoded somewhere out there in a gazillion message queues.



Related Search Term(s): concurrency

Pages 1 2 3 


Share this link: http://sdt.bz/36196
 
Most Read Latest News Blog Resources

Add comment


Name*
Email*  
Country     


  • Comment
Loading




close
NEXT ARTICLE
Coverity adds concurrency checking for C#
Prevent 4.3 also gained checkers for Win32 applications written in C and C++. Broader support for Microsoft products, particularly Windows and Visual Studio, has been implemented Read More...
 
 
 
 
News on Monday
more>>
SharePoint Tech Report
more>>


   

 
 

Download Current Issue
MAY 2012 PDF ISSUE

Need Back Issues?
DOWNLOAD HERE

Want to subscribe?


 
blogs tab
Slick...but who needs it?
compilr.com is a well-designed site and the folks behind it seem to have their heart in the right place. But...who needs it?
05/16/2012 12:45 PM EST

How to be a better software developer
Want to be a better developer? You won't get there by mastering an interesting language or learning a new set of APIs.
05/14/2012 12:18 PM EST

Wooing Galatea
Do yourself a favor and check out Galatea 2.2, a wonderful book by novelist Richard Powers.
05/12/2012 07:05 PM EST

The world as story
An artificial-intelligence system at Carnegie Mellon seeks to understand the world by making statements about it.
05/10/2012 06:39 AM EST

The Rise of the Brogrammer, or the Rise of the Sexist Programmer?
Women in Silicon Valley get vocal about sexist ads and campaigns that contribute to a tense work environment.
05/09/2012 03:14 PM EST

Retriever Communications Releases RADE3
Organizations concerned about the growing popularity of bring your own device to work policies may be comforted by the release of RADE3.
05/09/2012 11:46 AM EST

 

Events calendar tab
5/13/2012 to 5/18/2012
Boston
Lean-Kanban University

5/14/2012 to 5/18/2012
Denver
IDUG

5/23/2012 to 5/24/2012
Chicago
IEG

6/3/2012 to 6/7/2012
Orlando
IBM Rational

6/10/2012 to 6/15/2012
Las Vegas
SQE