The Most Overused Word in Parallel Programming: Reentrancy
I am a little late with my post this week, I apologize for that but I am still in Beijing at IWOMP with little time to post. Actually, now that the conference is over, I am staying for two more days to see the city, the Great Wall and a couple of other sites – which still leaves me with no time to post :grin:. Therefore you are going to have to live with a timeless one that I have recorded beforehand just for this purpose. Here it goes.
It is difficult enough already to teach my students about parallel programming, but when even some of the terms used are misleading, something is seriously wrong. Take this very simple example: the term reentrancy. I have just found the fourth definition of it, all from the field of parallel programming and all of them mean something (at least slightly) different.
- Goetz: But because intrinsic locks are reentrant, if a thread tries to acquire a lock that it already holds, the request succeeds. Reentrancy means that locks are acquired on a per-thread rather than per-invocation basis.
- Albahari: A method which is thread-safe in any scenario is called reentrant.
- Butenhof: The term “reentrant” is sometimes used to mean “efficiently thread-safe”. That is, the code was made thread-safe by some more sophisticated measures than converting the function or library into a single serial region.
- Wikipedia: A computer program or routine is described as reentrant if it can be safely called recursively or from multiple processes. To be reentrant, a function must hold no static data, must not return a pointer to static data, must work only on the data provided to it by the caller, and must not call non-reentrant functions.
*sigh*. You may argue that the last three definitions all mean the same thing. Yet, if you think about it some more you will realize that these tiny differences in wording make a whole lot of difference for a particular implementation. If I document my function as being reentrant, how do you know which definition I mean? How do you know what you can count on? You don’t, because you don’t know which definition of reentrancy I was aware of and using. I do realize that human languages are context sensitive. But four different meanings in the same field? Or if some of them really wanted to say the same thing: could we please be a little more precise? There has got to be a better way…