Abstract
Most programming languages use monitors with explicit signals for synchronization in shared-memory programs. Requiring programmers to signal threads explicitly results in many concurrency bugs due to missed notifications, or notifications on wrong condition variables. In this paper, we describe an implementation of an automatic signaling monitor in Java called AutoSynch that eliminates such concurrency bugs by removing the burden of signaling from the programmer. We show that the belief that automatic signaling monitors are prohibitively expensive is wrong. For most problems, programs based on AutoSynch are almost as fast as those based on explicit signaling. For some, AutoSynch is even faster than explicit signaling because it never uses signalAll, whereas the programmers end up using signalAll with the explicit signal mechanism.
AutoSynch} achieves efficiency in synchronization based on three novel ideas. We introduce an operation called closure that enables the predicate evaluation in every thread, thereby reducing context switches during the execution of the program. Secondly, AutoSynch avoids signalAll by using a property called relay invariance that guarantees that whenever possible there is always at least one thread whose condition is true which has been signaled. Finally, AutoSynch uses a technique called predicate tagging to efficiently determine a thread that should be signaled. To evaluate the efficiency of AutoSynch, we have implemented many different well-known synchronization problems such as the producers/consumers problem, the readers/writers problems, and the dining philosophers problem. The results show that AutoSynch is almost as efficient as the explicit-signal monitor and even more efficient for some cases.
- G. R. Andrews. Multithreaded, Parallel, and Distributed Programming. Addison-Wesley, MA, 2000.Google Scholar
- P. Brinch Hansen, The Programming language concurrent Pascal. IEEE Trans. Software Engineering, 1(2), 199--207, June, 1975. Google Scholar
Digital Library
- P. Brinch Hansen, Structured multiprogramming. Commun. ACM 15(7), 574--578, July 1972. Google Scholar
Digital Library
- P. A. Buhr, M. Fortier, and M. H. Coffin, Monitor Classification. ACM Computing Surveys, ACM, 27(1), 63--107, Mar. 1995. Google Scholar
Digital Library
- P. A. Buhr and A. S. Harji, Implicit-signal monitors. ACM Transactions on Programming Languages and Systems ACM, 27(6):1270--1343, Nov. 2005. Google Scholar
Digital Library
- D. R. Butenhof, Programming With Posix Threads. Addison-Wesley, MA, 1997. Google Scholar
Digital Library
- P. J. Courtois, F. Heymans, D. L. Parnars, Concurrent control with "readers" and "writers". Commun. ACM, 14(10), 667--668, Oct. 1971. Google Scholar
Digital Library
- E. W. Dijkstra, Cooperating Sequential Processes. Technical Report EWD-123, 1965. Google Scholar
Digital Library
- E. W. Dijkstra, The structure of the "THE"-multiprogramming system.Commun. ACM, 11(5), 341--346, May 1968. Google Scholar
Digital Library
- E. W. Dijkstra, Hierarchical Ordering of Sequential Processes. Acta Informatica, 1, 115--138, 1971.Google Scholar
Digital Library
- J. Gosling, B. Joy, and G. Steele, The Java Language Specification. 2nd ed. Addison-Wesley, MA, 2000. Google Scholar
Digital Library
- V. K. Garg and N. Mittal, A Critique of Java for Concurrent Programming, IEEE Distributed Systems online 6(9), 2005. Google Scholar
Digital Library
- A. Hejisberg, S. Wiltamuth, and P. Golde, C# Language Specification. Addison-Wesley, MA, 2003. Google Scholar
Digital Library
- C. A. R. Hoare, Monitors: an operating system structuring concept. Commun. ACM, 17(10), 549--557, Oct. 1974. Google Scholar
Digital Library
- Y.-J. Joung, Asynchronous group mutual exclusion. ACM Symposium on Principles of Distributed Computing, 51--60, Aug. 1998. Google Scholar
Digital Library
- J. L. W. Kessels. An alternative to event queues for synchronization in monitors. Commun. ACM, 20(7), 500--503, July 1977. Google Scholar
Digital Library
- V. Kodaganallur, Incorporating language processing into Java applications: a JavaCC tutorial. IEEE Software, 21(4), 70--77, July-Aug. 2004. Google Scholar
Digital Library
- D. Lea, The java.util.concurrent synchronizer framework. Science of Computer Programming, 58(3), 293--309, Dec. 2005. Google Scholar
Digital Library
- B. Stroustrup, The C++ Programming Language. 3rd ed. Addison- Wesley, MA, 1997. Google Scholar
Digital Library
- Yourkit LLC, Yourkit profiler. http://www.yourkir.comGoogle Scholar
Index Terms
AutoSynch: an automatic-signal monitor based on predicate tagging
Recommendations
AutoSynch: an automatic-signal monitor based on predicate tagging
PLDI '13: Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and ImplementationMost programming languages use monitors with explicit signals for synchronization in shared-memory programs. Requiring programmers to signal threads explicitly results in many concurrency bugs due to missed notifications, or notifications on wrong ...
Implicit-signal monitors
An implicit (automatic) signal monitor uses a waituntil predicate statement to construct synchronization, as opposed to an explicit-signal monitor using condition variables and signal/wait statements for synchronization. Of the two synchronization ...
Lock elision for read-only critical sections in Java
PLDI '10It is not uncommon in parallel workloads to encounter shared data structures with read-mostly access patterns, where operations that update data are infrequent and most operations are read-only. Typically, data consistency is guaranteed using mutual ...







Comments