Threads cannot be implemented as a library
Author:
Open Access
- 12 June 2005
- journal article
- Published by Association for Computing Machinery (ACM) in ACM SIGPLAN Notices
- Vol. 40 (6) , 261-268
Abstract
In many environments, multi-threaded code is written in a language that was originally designed without thread support (e.g. C), to which a library of threading primitives was subsequently added. There appears to be a general understanding that this is not the right approach. We provide specific arguments that a pure library approach, in which the compiler is designed independently of threading issues, cannot guarantee correctness of the resulting code.We first review why the approach almost works, and then examine some of the surprising behavior it may entail. We further illustrate that there are very simple cases in which a pure library-based approach seems incapable of expressing an efficient parallel algorithm.Our discussion takes place in the context of C with Pthreads, since it is commonly used, reasonably well specified, and does not attempt to ensure type-safety, which would entail even stronger constraints. The issues we raise are not specific to that context.Keywords
This publication has 20 references indexed in Scilit:
- The Java memory model2005
- An almost non-blocking stack2004
- Scalable lock-free dynamic memory allocation2004
- Fine-grain design space exploration for a cartographic SoC multiprocessorACM SIGARCH Computer Architecture News, 2003
- A new algorithm for scalar register promotion based on SSA form1998
- A methodology for implementing highly concurrent data objectsACM Transactions on Programming Languages and Systems, 1993
- CML1991
- Wait-free synchronizationACM Transactions on Programming Languages and Systems, 1991
- Determining average program execution times and their variance1989
- A case study in programming for parallel-processorsCommunications of the ACM, 1969