Deadlock and Lock Freedom in the Linear -Calculus

Deadlock and Lock Freedom in the Linear -Calculus

Deadlock and lock freedom in the linear π-calculus Luca Padovani To cite this version: Luca Padovani. Deadlock and lock freedom in the linear π-calculus. 2014. hal-00932356v2 HAL Id: hal-00932356 https://hal.inria.fr/hal-00932356v2 Preprint submitted on 20 Jan 2014 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Deadlock and lock freedom in the linear π-calculus Luca Padovani – Dipartimento di Informatica, Università di Torino, Italy Abstract—We study two refinements of the linear π-calculus that are not just technically simpler but also more accurate that ensure deadlock freedom (the absence of stable states with in establishing (dead)lock freedom of relevant processes. pending linear communications) and lock freedom (the eventual In a nutshell, we consider channel types of the form pι[t]n completion of pending linear communications). The main feature m of both type systems is a new form of channel polymorphism that where the polarity p (either input ? or output !), the type of affects their accuracy in a significant way: they are the first of the message (t), and the multiplicity (unlimited ! or linear 1), their kind that can deal with recursive processes communicating are just like in the linear π-calculus. In addition, we annotate in cyclic network topologies. channel types with two numbers, a priority n and m tickets. Priorities enforce an order on the use of channels: when a I. INTRODUCTION process owns two or more channels at the same time, channels The linear π-calculus [21] is a resource-aware model of with higher priority must be used before channels with lower communicating processes that distinguishes between linear priority (beware that we adopt the convention that “higher and unlimited channels. Unlimited channels can be used priority” means “smaller number”). In particular, an input without restrictions, while linear channels are meant to be u?(x):P is well typed if u has higher priority than all the used for exactly one communication. This intrinsic limitation is channels occurring in P and an output u!hvi is well typed if rewarded by several benefits, including specialized behavioral u has higher priority than v. This mechanism makes (1) ill equivalences for reasoning about communication optimiza- typed: it is not possible to assign two priorities h and k to a tions, the efficient implementation of linear channels, and the and b, for the structure of the process requires the simultaneous fact that communications on linear channels enjoy desirable satisfiability of the two constraints h < k and k < h. properties such as determinism and confluence. The value of Tickets limit the number of travels that channels can do: these benefits is amplified given that a significant fraction of u!hvi is well typed if v has at least one ticket; each time a channels in several actual systems happen to be linear. channel is sent as a message, one ticket is removed from its From an operational standpoint, the linear π-calculus only type; a channel with no tickets cannot travel and must be used guarantees that well-typed processes never communicate twice directly for performing a communication. This mechanism on the same linear channel. In practice, one may be interested makes (2) ill typed, because a is sent on c infinitely many in stronger guarantees, such as deadlock freedom [19] – the times and so it would need infinitely many tickets. absence of stable states with pending communications on The technique described thus far prevents deadlocks (if linear channels – or lock freedom [17], [22] – the possibility we just consider the constraints on priorities) and locks (if to complete pending communications on linear channels. A we also consider the constraints on tickets). Unfortunately, it paradigmatic example of deadlock is illustrated by the process fails to type most recursive processes. For example, the usual a?(x):b!hxi j b?(y):a!hyi (1) encoding of the factorial below where, for convenience, we have annotated linear names with their priority, is ill typed: where the left subprocess forwards on b the message x received h from a, and the right subprocess forwards on a the message y ∗fact?(x; y ): (3) h received from b. The process (1) is well typed when a and b if x = 0 then y !h1i k k k h are linear channels, but none of the pending communications else (νa )(fact!hx − 1; a i j a ?(z):y !hx × zi) on a and b can complete because of the mutual dependencies Since the newly created channel a is used in the same position between corresponding inputs and outputs. An example of lock as y in the recursive invocation of fact, we are led into thinking which is not a deadlock is illustrated by the process that a and y should have the same type hence the same priority c!hai j ∗c?(x):c!hxi j a!h1984i (2) h = k. This clashes with the input on a that blocks the output on y, requiring k < h. We see a symmetric phenomenon in where one occurrence of the linear channel a is repeatedly h k h k k sent over the unlimited channel c but never used for receiving ∗stream?(x; y ):(νa )(y !hx; a i j stream!hx + 1; a i) (4) the 1984 message. Note that (2), unlike (1), reduces forever, which generates a stream of integers. Here too a and y are but the communication pending on a cannot be completed. used in the same position and should have the same priority In this work we propose two refinements of the linear h = k, but the output y!hx; ai also requires h < k. π-calculus such that well-typed processes are (dead)lock free. We need some way to overcome these difficulties. Let us The techniques we put forward have been inspired by previous digress for a moment from fact and stream and consider ideas presented in [17]–[19], [22], except that by narrowing def h k h def h k k h the focus on the linear π-calculus we obtain type systems F1 = c?(x ):y !hx i and F2 = c?(x ; y ):y !hx i both of which forward a linear channel x received from c to are the same t1, t2, ::: that we initially guessed in (5), except the linear channel y. In both cases it must be k < h, but there that now t and s are regular hence finitely representable. is a key difference between F1 and F2: the priority of x in Summary of contributions. We strengthen the notion of F1 has a fixed lower bound k + 1 because y is free, while the linearity in the linear π-calculus by defining two type systems priority of x in F2 is arbitrary, provided that k < h, because ensuring the absence of deadlocks and locks involving linear y is bound. Rephrased in technical jargon, c is monomorphic channels, namely that linear channels are used exactly once in F1 and polymorphic in F2 with respect to priorities. The as opposed to at most once. We exploit the features of the fact that a channel like c is monomorphic or polymorphic linear π-calculus to devise a form of channel polymorphism depends on the presence or absence of free linear channels that allows us to deal with recursive processes that interleave in the continuation that follows the input on c. Normally this actions on different linear channels also in cyclic network information is not inferrable solely from the type of c, but topologies. Such configurations are common in the implemen- it turns out that we can easily approximate it in the linear tation of parallel algorithms and session-based networks, and π-calculus, where replicated processes cannot have free linear cannot be dealt with existing type systems for the generic channels because it is not known how many times they will π-calculus [17]–[19]. run. So, unlimited channels that are always used for replicated Outline. In Section II we quickly review syntax and semantics inputs (i.e., replicated channels [21]), are polymorphic. This of the π-calculus and give formal definitions of deadlock and is a very convenient circumstance, because replicated channels lock freedom. The type systems are described in Section III are the primary mechanism for implementing recursion. and illustrated on several examples that highlight the fea- Indeed, going back to fact and stream, we see that they tures of our approach. Section IV contains a more detailed are replicated channels, that is they are polymorphic. This and technical comparison with related work and particularly means that the mismatches between the priorities h of y and with [17]–[19]. Section V concludes and hints at ongoing and k of a in (3) and (4) can be compensated by this form of future developments. Additional technical material, extended polymorphism and these processes can be declared well typed. examples, and proofs of the results can be found in the The interplay between recursion and polymorphism leads to appendix, which is not formally part of the submission. a technical problem, though. Recall that in (4) there are two occurrences of a, one in stream!hx + 1; ai having the same II.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    22 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us