This post is an overview of the concurrency features of Java 7. This includes the Fork/Join Framework, the TransferQueue and the ThreadLocalRandom class
We've discussed differences between parallel, computational systems and concurrent, event handling systems. Areas of differences include:
Determinism: desirable vs impossible
Sign of parallel safety: same results vs correct results
Parallelism bugs: easy to pinpoint vs impossible to define
Queues: implementation detail vs part of the interface
Preemption: nearly useless vs nearly essential
In an earlier post I mentioned that one goal of the new introductory curriculum at Carnegie Mellon is to teach parallelism as the general case of computing, rather than an esoteric, specialized subject for advanced students. Many people are incredulous when I tell them this, because it immediately conjures in their mind the myriad complexities…
With the advent of multi-core processors concurrent programming is becoming indispensable. Scala's primary concurrency construct is actors. Actors are basically concurrent processes that communicate by exchanging messages. Actors can also be seen as a form of active objects where invoking a method corresponds to sending a message. The Scala Actors library provides both asynchronous and synchronous message sends (the latter are implemented by exchanging several asynchronous messages). Moreover, actors may communicate using futures where requests are handled asynchronously, but return a representation (the future) that allows to await the reply. This tutorial is mainly designed as a walk-through of several complete example programs Our first example consists of two actors that exchange a bunch of messages and then terminate. The first actor sends "ping" messages to the second actor, which in turn sends "pong" messages back (for each received "ping" message one "pong" message).
CUDA lets you work with familiar programming concepts while developing software that can run on a GP This is the first of a series of articles to introduce you to the power of CUDA -- through working code -- and to the thought process to help you map applications onto multi-threaded hardware (such as GPUs) to get big performance increases. Of course, not all problems can be mapped efficiently onto multi-threaded hardware, so part of my thought process will be to distinguish what will and what won't work, plus provide a common-sense idea of what might work "well-enough". "CUDA programming" and "GPGPU programming" are not the same (although CUDA runs on GPUs). CUDA permits working with familiar programming concepts while developing software that can run on a GPU. It also avoids the performance overhead of graphics layer APIs by compiling your software directly to the hardware (GPU assembly language, for instance), thereby providing great performance.
The result is a unified concurrency model providing both thread abstractions and event abstractions. We implemented the unified concurrency model in Haskell Our implementation demonstrates how to use these techniques by building an application-level thread library with support for multiprocessing and asynchronous I/O mechanisms in Linux. The thread library is type-safe, is relatively simple to implement, and has good performance. Application-level threads are extremely lightweight (scaling to 10,000,000 threads!) and our scheduler, which is implemented as a modular and extensible event-driven system, outperforms NPTL in I/O benchmarks.
This is an Erlang solution to "The Santa Claus problem", % as discussed by Simon Peyton Jones (with a Haskell solution using % Software Transactional Memory) in "Beautiful code". % He quotes J.A.Trono "A new exercise in concurrency", SIGCSE 26:8-10, 1994.
ATS is a PL with a highly expressive type system from the framework Applied Type System. Both dependent types and linear types are available in ATS. The current implementation of ATS (ATS/Anairiats) is written in ATS itself. It can be as efficient as C/C++ and supports * Functional programming. ATS uses eager call-by-value eval, it also supports lazy call-by-need evaluation. Linear types in ATS can often make FP run with high efficiency * Imperative programming. While features considered dangerous in other languages (e.g., explicit pointer arithmetic and explicit memory mgmt) are allowed in ATS, the type system of ATS is still able to guarantee that no run-time errors can occur * Concurrent programming. ATS, equipped with a multicore-safe implementation of garbage collection, can support multithreaded programming through the use of pthreads and parallel let * Modular programming. The module system of ATS is largely infuenced by that of Modula-3
Various concurrency primitives have been added to sequential programming languages, in order to turn them concurrent. Prominent examples are concurrent buffers for Haskell, channels in Concurrent ML, joins in JoCaml, and handled futures in Alice ML. Even though one might conjecture that all these primitives provide the same expressiveness, proving this equivalence is an open challenge in the area of program semantics. In this paper, we establish a first instance of this conjecture. We show that concurrent buffers can be encoded in the lambda calculus with futures underlying Alice ML. Our correctness proof results from a systematic method, based on observational semantics with respect to may and must convergence.
We introduce a new lambda calculus with futures, Lambda(fut), that models the operational semantics of concurrent statically typed functional programming languages with mixed eager and lazy threads such as Alice ML, a concurrent extension of Standard ML. Lambda(fut) is a minimalist extension of the call-by-value lambda-calculus that is sufficiently expressive to define and combine a variety of standard concurrency abstractions, such as channels, semaphores, and ports. Despite its minimality, the basic machinery of Lambda(fut) is sufficiently powerful to support explicit recursion and call-by-need evaluation. We present a static type system for Lambda(fut) and distinguish a fragment of Lambda(fut) that we prove to be uniformly confluent. This result confirms our intuition that reference cells are the sole source of indeterminism.
Peng Li's 2008 PhD dissertation, First, this dissertation presents a Haskell solution based on concurrency monads. This approach provides clean interfaces to both multithreaded programming and event-driven programming in the same application, but it also does not require native support of continuations from compilers or runtime systems. Then, this dissertation investigates for a generic solution to support lightweight concurrency in Haskell, compares several possible concurrency configurations and summarizes the lessons learned. The paper's summary explains what I like most about it: the project ... solves a systems problem using a language-based approach. Systems programmers, Haskell implementors and programming language designers may each find their own interests in this dissertation. Even if concurrency isn't your thing, section 6.3 describes the author's findings on the pros and cons of both purity and laziness in a systems programming context.
I didn't see anyone post them yet, so here are the slides from Tim Sweeney's POPL talk entitled "The Next Mainstream Programming Languages: A Game Developer's Perspective". I know Tim and I aren't the only game developers who follow LtU, and I figure even non-game developers might find them quite interesting!
concurrent paradigm, namely functional programming extended with threads and ports, which I call multi-agent dataflow programming. * The declarative concurrent subset (no ports) has no race conditions and can be programmed like a functional language. The basic concept is dataflow synchronization of single-assignment variables. A useful data structure is the stream, a list with dataflow tail used as a communication channel. * Nondeterminism can be added exactly where needed and minimally, by using ports - a named stream to which any thread can send. * All functional building blocks are concurrency patterns. Map, fold, filter, etc., are all useful for building concurrent programs. * Concurrent systems can be configured in any order and concurrently with actual use of the system. * Designing concurrent programs is any declarative part of the program can be put in own thread, loosening the coupling between system's parts * The paradigm is easily extended
T. Tu, X. Liu, L. Song, and Y. Zhang. Proceedings of the Twenty-Fourth International Conference on Architectural Support for Programming Languages and Operating Systems - ASPLOS \textquotesingle19, ACM, (2019)
J. Swalens, J. De Koster, and W. De Meuter. Proceedings of the 8th ACM SIGPLAN International Workshop on Programming Based on Actors, Agents, and Decentralized Control - AGERE 2018, page 33--43. ACM, (November 2018)
D. Aumayr, S. Marr, E. Gonzalez Boix, and H. Mössenböck. Proceedings of the 16th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes, page 157--171. ACM, (October 2019)
Q. Luo, F. Hariri, L. Eloussi, and D. Marinov. Proceedings of the 22Nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, page 643--653. ACM, (2014)
X. Chang, W. Dou, Y. Gao, J. Wang, J. Wei, and T. Huang. Proceedings of the 41st International Conference on Software Engineering, page 631--642. IEEE Press, (May 2019)
H. Sun, D. Bonetta, F. Schiavio, and W. Binder. Proceedings of the 2019 IEEE/ACM International Symposium on Code Generation and Optimization, page 61--72. IEEE Press, (2019)
C. Hsiao, S. Narayanasamy, E. Khan, C. Pereira, and G. Pokam. Proceedings of the Twenty-Second International Conference on Architectural Support for Programming Languages and Operating Systems, page 193--205. ACM, (2017)
V. Raychev, M. Vechev, and M. Sridharan. Proceedings of the 2013 ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages &\#38; Applications, page 151--166. ACM, (2013)
R. Utterback, K. Agrawal, J. Fineman, and I. Lee. Proceedings of the 28th ACM Symposium on Parallelism in Algorithms and Architectures, page 83--94. ACM, (2016)
A. Yoga, S. Nagarakatte, and A. Gupta. Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, page 833--845. ACM, (2016)
J. Protze, M. Schulz, D. Ahn, and M. Müller. Proceedings of the 27th International Symposium on High-Performance Parallel and Distributed Computing, page 144--155. ACM, (2018)
M. Cao, M. Zhang, A. Sengupta, and M. Bond. Proceedings of the 21st ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, page 20:1--20:13. ACM, (2016)
J. Roemer, K. Genc, and M. Bond. Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation, page 374--389. ACM, (2018)
J. Wang, W. Dou, Y. Gao, C. Gao, F. Qin, K. Yin, and J. Wei. Proceedings of the 32nd IEEE/ACM International Conference on Automated Software Engineering, page 520--531. IEEE Press, (2017)
G. Pinto, W. Torres, and F. Castor. Proceedings of the 6th Workshop on Evaluation and Usability of Programming Languages and Tools, page 39--46. New York, NY, USA, ACM, (2015)
D. Wu, L. Chen, Y. Zhou, and B. Xu. 2015 ACM/IEEE International Symposium on Empirical Software Engineering and Measurement (ESEM), page 1-10. (October 2015)
S. Fowler, S. Lindley, and P. Wadler. 31st European Conference on Object-Oriented Programming (ECOOP 2017), volume 74 of Leibniz International Proceedings in Informatics (LIPIcs), page 11:1--11:28. Dagstuhl, Germany, Schloss Dagstuhl--Leibniz-Zentrum für Informatik, (2017)
N. Cohen, A. Tal, and E. Petrank. Proceedings of the 22Nd ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, page 17--29. ACM, (2017)
S. Lu, J. Tucek, F. Qin, and Y. Zhou. Proceedings of the 12th International Conference on Architectural Support for Programming Languages and Operating Systems, page 37--48. ACM, (2006)
C. Flanagan, and S. Freund. Proceedings of the 30th ACM SIGPLAN Conference on Programming Language Design and Implementation, page 121--133. ACM, (2009)
T. Elmas, S. Qadeer, and S. Tasiran. Proceedings of the 28th ACM SIGPLAN Conference on Programming Language Design and Implementation, page 245--255. ACM, (2007)
S. Tasharofi, M. Pradel, Y. Lin, and R. Johnson. 2013 28th IEEE/ACM International Conference on Automated Software Engineering, page 114-124. (November 2013)
I. Cassar, and A. Francalanza. Proceedings 13th International Workshop on Foundations of Coordination Languages and Self-Adaptive Systems, page 54--68. (September 2014)
S. Tasharofi, R. Karmani, S. Lauterburg, A. Legay, D. Marinov, and G. Agha. Formal Techniques for Distributed Systems: Joint 14th IFIP WG 6.1 International Conference, FMOODS 2012 and 32nd IFIP WG 6.1 International Conference, FORTE 2012, Stockholm, Sweden, June 13-16, 2012. Proceedings, page 219--234. Springer, (2012)
D. Deng, W. Zhang, and S. Lu. Proceedings of the 2013 ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages & Applications, page 785--802. ACM, (2013)
N. Jalbert, and K. Sen. Proceedings of the Eighteenth ACM SIGSOFT International Symposium on Foundations of Software Engineering, page 57--66. New York, NY, USA, ACM, (2010)
J. De Koster, T. Van Cutsem, and W. De Meuter. Proceedings of the 6th International Workshop on Programming Based on Actors, Agents, and Decentralized Control, page 31--40. ACM, (2016)
C. Ritson, and J. Simpson. Communicating Process Architectures 2008, volume 66 of Concurrent Systems Engineering Series, page 293--307. Amsterdam, The Netherlands, IOS Press, (September 2008)
A. Matveev, N. Shavit, P. Felber, and P. Marlier. Proceedings of the 25th Symposium on Operating Systems Principles, page 168--183. New York, NY, USA, ACM, (2015)
J. Swalens, J. De Koster, and W. De Meuter. 30th European Conference on Object-Oriented Programming (ECOOP 2016), volume 56 of Leibniz International Proceedings in Informatics (LIPIcs), page 23:1--23:28. Dagstuhl, Germany, Schloss Dagstuhl--Leibniz-Zentrum fuer Informatik, (2016)
G. Steele, Jr., D. Lea, and C. Flood. Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications, page 453--472. ACM, (2014)
D. Bonetta, L. Salucci, S. Marr, and W. Binder. Proceedings of the 2016 ACM International Conference on Object Oriented Programming Systems Languages & Applications, page 531--547. ACM, (Nov 2, 2016)(acceptance rate 25%).
B. Daloze, S. Marr, D. Bonetta, and H. Mössenböck. Proceedings of the 2016 ACM International Conference on Object Oriented Programming Systems Languages & Applications, page 642--659. ACM, (Nov 2, 2016)(acceptance rate 25%).
L. Salucci, D. Bonetta, S. Marr, and W. Binder. Proceedings of the 21st ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, page 40:1--40:2. ACM, (March 2016)
B. Daloze, C. Seaton, D. Bonetta, and H. Mössenböck. Proceedings of the 10th International Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems, (2015)
S. Abramsky. Electronic Notes in Theoretical Computer Science, (2006)Proceedings of the Workshop "Essays on Algebraic Process Calculi" (APC 25)Proceedings of the Workshop "Essays on Algebraic Process Calculi" (APC 25).
S. Marr, E. Gonzalez Boix, and H. Mössenböck. Proceedings of the 9th Arbeitstagung Programmiersprachen, volume 1559 of ATPS'16, page 91--95. CEUR-WS, (Feb 25, 2016)
J. McAffer. ECOOP’95 — Object-Oriented Programming, 9th European Conference, Åarhus, Denmark, August 7–11, 1995, volume 952 of Lecture Notes in Computer Science, Springer Berlin Heidelberg, (1995)
P. Liu, X. Zhang, O. Tripp, and Y. Zheng. Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, page 55--64. ACM, (2015)
Y. Hayduk, A. Sobe, and P. Felber. Distributed Applications and Interoperable Systems, volume 9038 of Lecture Notes in Computer Science, Springer, (2015)
B. Claudel, Q. Sabah, and J. Stefani. Formal Techniques for Distributed Objects, Components, and Systems, volume 9039 of Lecture Notes in Computer Science, Springer, (2015)
Y. Honda, and A. Yonezawa. ECOOP ’88 European Conference on Object-Oriented Programming, volume 322 of Lecture Notes in Computer Science, Springer Berlin Heidelberg, (1988)
F. David, G. Thomas, J. Lawall, and G. Muller. Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages &\#38; Applications, page 291--307. ACM, (2014)
J. Zhou, X. Xiao, and C. Zhang. Proceedings of the 34th International Conference on Software Engineering, page 892--902. Piscataway, NJ, USA, IEEE Press, (2012)
M. Zhang, J. Huang, M. Cao, and M. Bond. Proceedings of the 20th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, page 97--108. ACM, (2015)