Appraising Fairness in Languages for Distributed Programming*
Total Page:16
File Type:pdf, Size:1020Kb
Distributed Computing (1988) 2:226-241 © Springer-Verlag 1988 Appraising fairness in languages for distributed programming* Krzysztof R. Apt1, Nissim Francez 2 and Shmuel Katz 2 1 Center for Mathematics and Computer Science, Kruislaan 413, NL-1098SJ Amsterdam, The Netherlands and Department of Computer Science, University of Texas at Austin, Austin TX 78712-1188, USA 2 Department of Computer Science, The Technion, Haifa, Israel Krzysztof R. Apt was born elude the methodology of programming, specification methods, in 1949 in Poland. Received his program verification and semantics, distributed programming, Ph.D. in 1974 from Polish Aca data structures, and programming languages. demy of Sciences in Warsaw in mathematical logic. From 1974 until 1981 worked at various Nissim Francez received his scientific institutions in the B.A. in Mathematics and Phi Netherlands and from 1981 un losophy from the Hebrew Uni til 1987 at C.N.R.S. in Paris, versity in Jerusalem, and his France. Spent 1985 as a visiting M.Sc. and Ph.D. in computer scientist at IBM Research science (1976) from the Weiz Centre in Yorktown Heights, mann Institute of Science, Re U.S.A. Currently holding an hovot, Israel. In 1976-77 he Endowed Professorship at the spent a postdoctoral year at Department of Computer Sci- Queen's university, Belfast, ences at the University of Texas where he was introduced by at Austin; also a senior research scientist at the Centre for C.A.R. Hoare to CSP. In 1977 Mathematics and Computer Science in Amsterdam, the Nether 78 he was an assistant professor lands. His research interests include program correctness and at USC, Los Angeles. From semantics, methodology of distributed computing, use of logic 1978 he is with the Computer as a programming language and non-standard forms of reason Science Department at the ing. He has served on editorial boards of a number of journals Technion. In 1982-83 he was on a sabbatical leave at IBM and program committees of numerous conferences in computer T.J. Watson Research Center. He has been a consultant for science. Lectured in a dozen countries on four continents. Also, MCC's software technology program, working on multiparty he has run two marathons and crossed Sumatra on a bicycle. activities in distributed systems. He had summer appointments in Harvard University, IBM T.J. Watson Research Center, Utrecht University, CWI (Amsterdam) and at MCC. He also Shmuel Katz received his served in several program committees. His research interests B.A. in Mathematics and Eng include program verification and the semantics of programming lish Literature from U.C.L.A., languages, mainly for concurrent and distributed programming. and his M.Sc. and Ph.D. in Is also interested in logic programming and recursive query Computer Science ( 1976) from evaluation and in compiler constraction. He is the author of the Weizmann Institute in Re the first book on Fairness. Unfortunately, he is incapable of hovot, Israel. From 1976 to Marathon running .... 1981 he was a researcher at the IBM Israel Scientific Center. Presently, he is a Senior Lec Abstract. The relations among various languages turer in the Computer Science and models for distributed computation and var Department at the Technion in ious possible definitions of fairness Haifa, Israel. In 1977 78 he are considered. visited for a year at the Univer Natural semantic criteria are presented which an sity of California, Berkeley, and acceptable notion of fairness should satisfy. These in 1984 85 was at the U niversi- are then used to demonstrate differences among ty of Texas at Austin. He has also been a consultant for the the basic models, the added power of the fairness MCC Software Technology Program. His research interests in- notion, and the sensitivity of the fairness notion 0.ffprint requests to: K.R. Apt to irrelevant semantic interleavings of independent *A preliminary version of this work appeared in [AFK] operations. These results are used to show that K.R. Apt et al.: Fairness for distributed programming 227 from the considerable variety of commonly used results linking the criteria and the models. In subse possibilities, only strong process fairness is appro quent sections the formal definitions are given, and priate for CSP if these criteria are adopted. We the theorems and proofs which lead to these results also show that under these criteria, none of the are presented. commonly used notions of fairness are fully accept noted above, any definition of fair able for a model with an n-way synchronization Feasibility. As (the "unfair" mechanism. The notion of fairness most often men ness excludes some of the executions be legal executions tioned for Ada is shown to be fully acceptable. ones) which otherwise would according to a semantics of the com For a model with nonblocking send operations, of a program model. A necessary requirement of any some variants of common fairness definitions are putational for a computational model appraised, and two are shown to satisfy the sug definition of fairness remain after gested criteria. is to have some legal computation this exclusion, for every possible program and ini Key words: Fairness Distributed computing - tial state. That is, for every legal program and ini Communication - Partial order semantics - Se tial state some (finite or infinite) fair computation mantic criteria does exist. This restriction is closely related to the idea of implementing fairness by means of sche dulers. Without it, no scheduler - which must pro duce one of the fair computations - could correctly 1 Introduction treat the fairness. Moreover, since any reasonable 'predict' the possible continua Fairness is an important concept which naturally scheduler cannot computation, it should arises in the study of nondeterministic systems, in tions at each point of the partial computation particular when dealing with concurrent systems. be possible to extend every criteri A very general formulation is a statement of the to a fair one. This is the proposed feasibility the above necessary require form: if a certain choice is possible sufficiently of on, and it subsumes ment. ten, then it is sufficiently often taken. Depending example of an unfeasible definition on the definitions of a "choice", "possible", and As a simple ( GC) [DJ, consid "sufficiently often", different notions of fairness ar of fairness for guarded commands fairness definition: all choices (re ise. A variety of these fairness notions have been er the following ferred to as directions) which are infinitely often introduced in the literature and studied both from must eventually be chosen equally often. a proof theoretic and a semantic point of view. possible In Figure 1 a nonterminating program P is Semantics is usually introduced by means of a com for which there is no computation sequence putational model which defines legal computa shown, satisfying the above definition, even though both tions. A two-leveled approach is most often taken are infinitely often possible. Thus no in which first the legal computations are described, directions scheduler can be devised, and the fairness notion and then a fairness notion is used to exclude some is not feasible for that model. (In fact, feasible defi additional computations which otherwise would be nitions of such a fairness notion must incorporate legal. An overview, examples, and further refer the set of choices which are jointly possible at each ences may be found in [Fr]. stage, as in [GFK !].) For nondeterministic programs some of the fairness notions include weak fairness (also called Equivalence robustness. For concurrent programs, justice), strong fairness, equifairness, and extreme the computational model used induces a depen fairness. For CSP [HJ and other models for distrib dency relation among actions. For example, an in uted computing, at least six reasonable variants put action of a receiving process depends on a cor have been defined and investigated. This wide vari responding output action of a sending process. The ety of possibilities leads to a confusing situation: computations of asynchronous, distributed systems selection of a particular definition of fairness for are often modeled by interleaving the (atomic) ac any particular model or language relies almost ex tions of their component processes. However, it clusively on subjective, implicit criteria. is clear that the order of execution of independent In this paper, we suggest three simple semantic actions in such an interleaving is arbitrary. Thus criteria which can aid in determining which notions two execution sequences which are identical up to are appropriate for which computational model. the order of two independent actions should be The criteria we propose are termed feasibility, equivalent. This leads to the second criterion: a equivalence robustness, and livenes!! enhancement. definition of fairness is equivalence robust for a Below we informally explain the criteria and the computational model if it respects the equivalence 228 K.R. Apt et al.: Fairness for distributed programming P: :x,=1; *[true-> x'=x+ 1 Process Fairness - satisfies all three criteria. The 0 x mod 3=0---+ x:=x+ !]. joint action of CSP involves synchronous commu Fig. I nication between a pair of processes. In section 4, we study the case of N-way communication (for induced by that model. That is, for two infinite arbitrary N > 2), i.e., a joint action with synchro sequences which differ by a possibly infinite nous communication among N processes. We show number of interchanges of independent actions (i.e., that none of the six common fairness definitions equivalent sequences), either both are fair accord we consider satisfy all of the criteria. The difference ing to the given definition, or both are unfair. If between the 2-way and N-way cases lies in a this criterion is not satisfied, then fairness depends greater possibility of "conspiracies" when N > 2.