An Introduction to Programming with Threads
Andrew D. Birrell · 1996
This paper provides an introduction to writing concurrent programs with "threads". A threads facility allows you to write programs with multiple simultaneous points of execution, synchronizing through shared memory. The paper describes the basic thread and synchronization primitives, then for each primitive provides a tutorial on how to use it. The tutorial sections provide advice on the best ways to use the primitives, give warnings about what can go wrong and offer hints about how to avoid these pitfalls. The paper is aimed at experienced programmers who want to acquire practical expertise in writing concurrent programs. CR categories and Subject Descriptors: D.1.4 [Programming Techniques]: Concurrent Programming; D.3.3 [Programming Languages]: Language Constructs---Concurrent programming structures; D.4.1 [Operating Systems]: Process Management General Terms: Design, Languages, Performance Additional Key Words and Phrases: Threads, Concurrency, Multi-processing, Synchronization CONTENTS Introduction......................................................... .............................................1 Why use concurrency? ..................................................................... ...................2 The design of a thread facility ..................................................................... .........3 Using a Mutex: accessing shared data ....................................................................7 Using a Condition variable: scheduling shared resources.......................................... 14 Using Fork: working in parallel ..................................................................... .... 22 Using Alert: diverting the flow of control ............................................................ 27 Additional techniques .............
Cited by 135 works.
Authors
References
- Implementing remote procedure calls
- Mach: A New Kernel Foundation for UNIX Development.
- Experience with processes and monitors in Mesa
- Traffic control in a multiplexed computer system
- A New Kernel Foundation for Unix Development
- Extending Modula-2 to Build Large, Integrated Systems
- The Larch Family of Specification Languages
- Synchronization primitives for a multiprocessor: a formal specification
- WorkCrews: An abstraction for controlling parallelism
- Evolving the UNIX System Interface to Support Multithreaded Programs