Resource-Passing Concurrent Programming
The use of types to deal with access capabilities of program entities is becoming increasingly popular.
In concurrent logic programming, the first attempt was made in Moded Flat GHC in 1990, which gave polarity structures (modes) to every variable occurrence and every predicate argument. Strong moding turned out to play fundamental rôles in programming, implementation and the in-depthunderstanding of constraint-based concurrent computation.
The moding principle guarantees that each variable is written only once and encourages capability-conscious programming. Furthermore, it gives less generic modes to programs that discard or duplicate data, thus providing the view of “data as resources.” A simple linearity system built upon the mode system distinguishes variables read only once from those read possibly many times, enabling compile-time garbage collection. Compared to linear types studied in other programming paradigms, the primary issue in constraint-based concurrency has been to deal with logical variables and highly non-strict data structures they induce.
In this paper, we put our resource-consciousness one step forward and consider a class of ‘ecological’ programs which recycle or return all the resources given to them while allowing concurrent reading of data structures via controlled aliasing. This completely recyclic subset enforces us to think more about resources, but the resulting programs enjoy high symmetry which we believe has more than aesthetic implications to our programming practice in general.
The type system supporting recyclic concurrent programming gives a [−1, +1] capability to each occurrence of variable and function symbols (constructors), where positive/negative values mean read/write capabilities, respectively, and fractions mean non-exclusive read/write paths. The capabilities are intended to be statically checked or reconstructed so that one can tell the polarity and exclusiveness of each piece of information handled by concurrent processes. The capability type system refines and integrates the mode system and the linearity system for Moded Flat GHC. Its arithmetic formulation contributes to the simplicity.
The execution of a recyclic program proceeds so that every variable has zero-sum capability and the resources (i.e., constructors weighted by their capabilities) a process absorbs match the resources it emits. Constructors accessed by a process withan exclusive read capability can be reused for other purposes.
The first half of this paper is devoted to a tutorial introduction to constraint-based concurrency in the hope that it will encourage crossfertilization of different concurrency formalisms.
KeywordsLogic Program Mode Graph Logical Variable Mode Constraint Program Clause
Unable to display preview. Download preview PDF.
- 2.Ajiro, Y., Ueda, K. and Cho, K., Error-Correcting Source Code. In Proc. Fourth Int. Conf. on Principles and Practice of Constraint Programming (CP’98), LNCS 1520, Springer-Verlag, 1998, pp. 40–54.Google Scholar
- 3.Ajiro, Y. and Ueda, K., Kima: an Automated Error Correction System for Concurrent Logic Programs. To appear in Automated Software Engineering, 2001.Google Scholar
- 5.Chikayama, T. and Kimura, Y., Multiple Reference Management in Flat GHC. In Logic Programming: Proc. of the Fourth Int. Conf. (ICLP’87), The MIT Press, 1987, pp. 276–293.Google Scholar
- 6.Chikayama, T., Operating System PIMOS and Kernel Language KL1. In Proc. Int. Conf. on Fifth Generation Computer Systems 1992 (FGCS’92), Ohmsha and IOS Press, Tokyo, 1992, pp. 73–88.Google Scholar
- 7.Chikayama, T., Fujise, T. and Sekita, D., A Portable and Efficient Implementation of KL1. In Proc. 6th Int. Symp. on Programming Language Implementation and Logic Programming (PLILP’94), LNCS 844, Springer-Verlag, 1994, pp. 25–39.Google Scholar
- 9.Crary, K. and Weirich, S., Resource Bound Certification. In Proc. 27th ACM Symp. on Principles of Programming Languages (POPL’00), 2000, pp. 184–198.Google Scholar
- 10.Fujita, H. and Hasegawa, R., A Model Generation Theorem Prover in KL1 Using a Ramified-Stack Algorithm. In Proc. Eighth Int. Conf. on Logic Programming (ICLP’91), The MIT Press, Cambridge, MA, 1991, pp. 535–548.Google Scholar
- 11.Fournet, C., Gonthier, G. Lévy, J.-J., Maranget, L. and Rémy, D., A Calculus of Mobile Agents. In Proc. 7th Int. Conf. on Concurrency Theory (CONCUR’96), LNCS 1119, Springer-Verlag, 1996, pp. 406–421.Google Scholar
- 13.Gay, S. and Hole, M., Types and Subtypes for Client-Server Interactions. In Proc. European Symp. on Programming (ESOP’99), LNCS 1576, Springer-Verlag, 1999, pp. 74–90.Google Scholar
- 16.Hughes, J. and Pareto, L., Recursion and Dynamic Data-structures in Bounded Space: Towards Embedded ML Programming. In Proc. Fourth ACM SIGPLAN Int. Conf. on Functional Programming (ICFP’99), 1999, pp. 70–81.Google Scholar
- 18.Kobayashi, N., Quasi-Linear Types In Proc. 26th ACM Symp. on Principles of Programming Languages (POPL’99), ACM, 1999, pp. 29–42.Google Scholar
- 20.Mackie, I., Lilac: A Functional Programming Language Based on Linear Logic. J. Functional Programming, Vol. 4, No. 4 (1994), pp. 1–39.Google Scholar
- 21.Mazur, N., Janssens, G. and Bruynooghe, M., A Module Based Analysis for Memory Reuse in Mercury. In Proc. Int. Conf. on Computational Logic (CL2000), LNCS 1861, Springer-Verlag, 2000, pp. 1255–1269.Google Scholar
- 22.Merro, M., Locality in the π-calculus and Applications to Distributed Objects. PhD Thesis, Ecol des Mines de Paris, 2000.Google Scholar
- 23.Miller, D., A Survey on Linear Logic Programming. The Newsletter of the European Network in Computational Logic, Vol. 2, No. 2 (1995), pp.63–67.Google Scholar
- 24.Niehren, J. and Müller, M., Constraints for Free in Concurrent Computation. In Proc. Asian Computing Science Conf. (ACSC’95), LNCS 1023, Springer-Verlag, 1995, pp. 171–186.Google Scholar
- 25.Sakamoto, K., Matsumiya, S. and Ueda, K., Optimizing Array Processing of Parallel KLIC. In IPSJ Trans. on Programming, Vol. 42, No. SIG 3(PRO 10) (2001), pp. 1–13 (in Japanese).Google Scholar
- 27.Saraswat, V. A., Kahn, K. and Levy, J., Janus: A Step Towards Distributed Constraint Programming. In Proc. 1990 North American Conf. on Logic Programming (NACLP’90), The MIT Press, Cambridge, MA, 1990, pp. 431–446.Google Scholar
- 28.Saraswat, V. A. and Rinard, M., Concurrent Constraint Programming (Extended Abstract). In Proc. 17th Annual ACM Symp. on Principles of Programming Languages (POPL’90), ACM, 1990, pp. 232–245.Google Scholar
- 29.Sastry, A. V. S. and Clinger, W., Parallel Destructive Updating in Strict Functional Languages. In Proc. 1994 ACM Conf. on LISP and Functional Programming, 1994, pp. 263–272.Google Scholar
- 30.Shapiro, E. Y., Concurrent Prolog: A Progress Report. IEEE Computer, Vol. 19, No. 8 (1986), pp. 44–58.Google Scholar
- 35.Turner, D. N., Wadler, P. and Mossin, C., Once Upon a Type. In Proc. Seventh Int. Conf. on Functional Programming Languages and Computer Architecture (FPCA’95), ACM, 1995, pp. 1–11.Google Scholar
- 36.Ueda, K., Guarded Horn Clauses. ICOT Tech. Report TR-103, ICOT, Tokyo, 1985. Also in Logic Programming’ 85, Wada, E. (ed.), LNCS 221, Springer-Verlag, 1986, pp. 168–179.Google Scholar
- 37.Ueda, K., Guarded Horn Clauses. D. Eng. Thesis, Univ. of Tokyo, 1986.Google Scholar
- 38.Ueda, K. and Furukawa, K., Transformation Rules for GHC Programs. In Proc. Int. Conf. on Fifth Generation Computer Systems 1988 (FGCS’88), ICOT, Tokyo, 1988, pp. 582–591.Google Scholar
- 40.Ueda, K. and Morita, M., Message-Oriented Parallel Implementation of Moded Flat GHC. New Generation Computing, Vol. 11, No. 3-4 (1993), pp. 323–341.Google Scholar
- 42.Ueda, K., Moded Flat GHC for Data-Parallel Programming. In Proc. FGCS’94 Workshopon Parallel Logic Programming, ICOT, Tokyo, 1994, pp. 27–35.Google Scholar
- 44.Ueda, K., klint-Static Analyzer for KL1 Programs. Available from http://www.icot.or.jp/ARCHIVE/Museum/FUNDING/funding-98-E.html, 1998.
- 45.Ueda, K., Concurrent Logic/Constraint Programming: The Next 10 Years. In The Logic Programming Paradigm: A 25-Year Perspective, Apt, K. R., Marek, V. W., Truszczynski M., and Warren D. S. (eds.), Springer-Verlag, 1999, pp. 53–71.Google Scholar
- 46.Ueda, K., Linearity Analysis of Concurrent Logic Programs. In Proc. Int. Workshop on Parallel and Distributed Computing for Symbolic and Irregular Applications, Ito, T. and Yuasa, T. (eds.), World Scientific, 2000, pp. 253–270.Google Scholar
- 47.van Emden, M. H. and de Lucena Filho, G. J., Predicate Logic as a Language for Parallel Programming. In Logic Programming, Clark, K. L. and Tarnlund, S.-Å. (eds.), Academic Press, London, 1982, pp. 189–198.Google Scholar
- 48.Victor, B., The Fusion Calculus: Expressiveness and Symmetry in Mobile Processes, PhD Thesis, Uppsala Univ., 1998.Google Scholar
- 49.Wadler, P., Linear Types Can Change theWorld! In Prof. IFIP TC2 Working Conf. on Programming Concepts and Methods, Broy, M. and Jones, C. (eds.), North-Holland, 1990, pp. 347–359.Google Scholar
- 50.Walker, D. P., Typed Memory Management. PhD thesis, Cornell Univ., 2001.Google Scholar