Assumption Commitment Types for Resource Management in Virtually Timed Ambients

by   Einar Broch Johnsen, et al.

This paper introduces a type system for resource management in the context of nested virtualization. With nested virtualization, virtual machines compete with other processes for the resources of their host environment in order to provision their own processes, which could again be virtual machines. The calculus of virtually timed ambients formalizes such resource provisioning, extending the capabilities of mobile ambients to model the dynamic creation, migration, and destruction of virtual machines. The proposed type system uses assumptions about the outside of a virtually timed ambient to guarantee resource provisioning on the inside. We prove subject reduction and progress for well-typed virtually timed ambients, expressing that the upper bounds on resource needs are preserved by reduction and that processes will not run out of resources.



page 1

page 2

page 3

page 4


Containers Placement and Migration on Cloud System

Currently, many businesses are using cloud computing to obtain an entire...

CAMIG: Concurrency-Aware Live Migration Management of Multiple Virtual Machines in SDN-enabled Clouds

By integrating Software-Defined Networking and cloud computing, virtuali...

Out of Hypervisor (OoH): When Nested Virtualization Becomes Practical

This paper introduces Out of Hypervisor (OoH), a new research axis close...

Comparative Study of Virtual Machines and Containers for DevOps Developers

In this work, we plan to develop a system to compare virtual machines wi...

Runners in action

Runners of algebraic effects, also known as comodels, provide a mathemat...

Parallel Virtual Machines Placement with Provable Guarantees

Network Function Virtualization (NFV) carries the potential for on-deman...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Virtualization enables the resources of an execution environment to be represented as a software layer, a so-called virtual machine. Software processes are agnostic to whether they run on a virtual machine or directly on physical hardware. A virtual machine is itself such a process, which can be executed on another virtual machine. Technologies such as VirtualBox, VMWare ESXi, Ravello HVX, Microsoft Hyper-V, and the open-source Xen hypervisor increasingly support running virtual machines inside each other in this way. This nested virtualization, originally introduced by Goldberg [1], is necessary to host virtual machines with operating systems which themselves support virtualization [2], such as Microsoft Windows 7 and Linux KVM. Use cases for nested virtualization include end-user virtualization for guests, software development, and deployment testing. Nested virtualization is also a crucial technology to support the hybrid cloud, as it enables virtual machines to migrate between different cloud providers [3].

To study the logical behavior of virtual machines in the context of nested virtualization, this paper introduces a type-based analysis for a calculus of virtual machines. An essential feature of virtual machines, captured by this calculus, is that a virtual machine competes with other processes for the resources available in their execution environment, in order to provision resources to the processes inside the virtual machine. Another essential feature of virtual machines is migration. From an abstract perspective, virtual machines can be seen as mobile processes which can move between positions in a hierarchy of nested locations.

We develop our type system for virtually timed ambients [4], a calculus of mobile virtual locations with explicit resource provisioning, based on mobile ambients [5]. Our goal is to statically approximate an upper bound on resource consumption for systems of virtual machines expressed in this calculus. The calculus features a resource called virtual time, reflecting local execution capacity, which is provisioned to an ambient by its parent ambient, similar to time slices that an operating system provisions to its processes. With several levels of nested virtualization, virtual time becomes a local notion which depends on an ambient’s position in the location hierarchy. Virtually timed ambients are mobile, reflecting that virtual machines may migrate between host virtual machines. Migration affects the execution speed of processes inside the virtually timed ambient which is moving as well as in its host before and after the move. Consequently, the resources required by a process change dynamically when the topology changes.

The distinction between the inside and outside of a virtually timed ambient (or a virtual machine) is a challenge for compositional analysis; we have knowledge of the current contents of the virtual machine, but not of what can happen outside its borders. This challenge is addressed in our type system by distinguishing assumptions about ambients on the outside of the virtually timed ambient from commitments to ambients on the inside. To statically approximate the effects of migration, an ambient’s type imposes a bound on the ambients it can host. Type checking fails if the ability to provision resources for an incoming ambient in a timely way cannot be statically guaranteed.

The ambient calculus has previously been enriched with types (e.g., [6]). Exploiting the explicit notion of resource provisioning in virtually timed ambients (including a fair scheduling strategy and competition for resources between processes), our type system captures the resource capacity of a virtually timed ambient and an upper bound on the number of its subambients. The type system thereby provides concrete results on resource consumption in an operational framework. Resource dependency in the type system is expressed using coeffects. The term coeffect was coined by Petricek, Orchard, and Mycroft [7, 8] to capture how a computation depends on an environment rather than how it affects the environment. In our setting, coeffects capture how a process depends on its environment by an upper bound on the resources needed by the process.

Contributions. The main technical contributions of this paper are

  • an assumption commitment type system with effects and coeffects, which provides a static approximation of constraints regarding the capacity of virtually timed ambients and an upper bound on their resource usage; and

  • a proof of the soundness of resource management for well-typed virtually timed ambients in terms of a subject reduction theorem which expresses that the upper bounds on resources and on the number of subambients are preserved under reduction, and a progress theorem which expresses that well-typed virtually timed ambients will not run out of resources.

To the best of our knowledge, this is the first assumption commitment style type system for resource types and nested locations.

Paper overview. Section 2 introduces virtually timed ambients. Section 3 presents the type system for resource management. In Section 4, we prove the soundness of the type system in terms of subject reduction and progress. We discuss related work and conclude in Sections 5 and 6.

2 Virtually Timed Ambients

Mobile ambients [5] are processes with a concept of location, arranged in a hierarchy which may change dynamically. Interpreting these locations as places of deployment, virtually timed ambients [4, 9] extend mobile ambients with notions of virtual time and resource consumption. The timed behavior of a process depends on the one hand on the local timed behavior, and on the other hand on the placement or deployment of the process in the hierarchical ambient structure. Virtually timed ambients combine timed processes and timed capabilities with the mobility and location properties of the mobile ambient calculus.

Compared to the previous work [4, 9], we here present a slightly simplified version of virtually timed ambients which assumes a uniform speed for all ambients in the hierarchy. This simplification does not mean the ambients proceed uniformly with respect to time: the progress of an ambient still depends on its position in the hierarchy and the number of sibling ambients that compete for time slices at the given level. Since an ambient system can change its structure, i.e., its hierarchy, an ambient’s local access to time slices may also dynamically change. Thus, the simplification by uniform speed is not conceptual, but it allows a simpler formulation of the type system by removing fractional representations of speed in scheduling and the resulting (easy but cumbersome) calculations.

Definition 1 (Virtually timed ambients)

The syntax of virtually timed ambients is as follows:

The syntax is almost unchanged from that of standard mobile ambients (e.g., [5]), the only syntactic addition is an additional capability c explained below. In the sequel, we mostly omit the qualification “timed” or “virtually timed” when speaking about processes, capabilities, etc. Processes include the inactive process 0, parallel composition and replication , the latter conceptually represents an unbounded parallel composition of a process, with capability as “guard”. The -binder or restriction operator, makes the name local, as in the -calculus, ambient calculus and related formalisms. Ambients are named processes. The standard mobile ambient capabilities in, out, and open allow a process to change the nested ambient structure by moving an ambient into or out of another ambient, or by dissolving an ambient altogether.

The additional capability c is specific for the virtually timed extension and abstractly represents the need of the process for a resource in order to continue its execution (i.e., c can be read as “consume”). Thus, the consume capability relates to computation cost in frameworks for cost analysis (e.g., [10, 11]). In our setting, the c-capabilities consume resources which can be thought of time slices and which are governed by a scheduler. A scheduler is local to an ambient and its responsibility is to fairly schedule the processes that are directly contained in the ambient it is managing. Since ambients are nested, the scheduler also has to allocate time slices or resources to subambients, thereby delegating the fair allocation of time slices at the level of the subambients to their respective schedulers. To achieve a fair schedule, the semantics adopts a simple round-based strategy. In first approximation: no process is served twice, unless all other processes at that level have been served at least once. This round-based scheme is slightly more refined in that the number of processes per ambient is not fixed as ambients may move inside the hierarchy and even dissolve.

To capture the outlined scheduling strategy in operational rules working on the syntax of ambients, we augment the grammar of Def. 1 with additional run-time syntax (highlighted below). When needed, we refer to the original syntax from Def. 1 as static syntax. The run-time syntax uses the notation to indicate that processes, including ambients, are frozen and to denote either or .

Frozen processes are not eligible for scheduling. For regular (non-ambient) processes, only processes prefixed by the consume capability c will be controlled in this way; other processes are unconditionally enabled. Consequently, we only need as additional run-time syntax , capturing a deactivated resource capability. Similarly denotes a timed ambient which is not eligible for scheduling. Apart from scheduling, a frozen ambient is treated as any other ambient : the ordinary, untimed capabilities address ambients by their name without the additional scheduling annotation. Likewise, -binders and corresponding renaming and algebraic equivalences treat names as identical to . Unless explicitly mentioned, we assume in the following run-time syntax, i.e., may contain occurrences of and . Time slices are denoted by ticks, and come in two forms and . We may think of the first form as representing incoming ticks into an ambient, typically from the parent ambient, the second form represents time slices handed out to the local processes by the local scheduler. The -capability similarly accepts an incoming tick. Let denote the set of names for ambients contained in .

2.1 Semantics

The semantics of virtually timed ambients is given as a reduction system. The rules for structural congruence are equivalent to those for mobile ambients (and therefore omitted here). Besides structural congruence, the reduction relation for virtually timed ambients builds upon observables, also known as barbs. Barbs, originally introduced for the -calculus [12], capture a notion of immediate observability. In the ambient calculus, these observations concern the presence of a top-level ambient whose name is not restricted [13]. In our context, the barbs are adapted to express top-level schedulability, i.e., an ambient’s ability to receive a tick. In addition, we will need to capture that a sub-process is able to receive a tick from it’s local scheduler. To specify that, we denote by (or simply by ) a context, i.e., a process with a (unique) hole in place of a process, and write for the context with its hole replaced by . The observability predicates (or “tick-barbs”) resp.  are then defined as follows, where is a tuple of names:

Definition 2 (Barbs)

A process strongly barbs on , written , if or . A process strongly barbs on in context , written , if for some process with .

Note that the ambient name may well be hidden, i.e., mentioned in . Barbing on the ambient name , written , would require that where , in contrast to the definition of . This more conventional notion of strong barbing [13] expresses that an ambient is available for interaction with the standard ambient capabilities; ambients whose name is unknown are not available to be contacted by other ambients and therefore, their name is excluded in the observability predicate . In contrast, strong barbing as defined in Def. 2 captures an ambient’s ability to receive ticks and thus, the definition will allow hidden ambients to be served by the local scheduler. However, the name of the ambient must not be frozen : ambients that have been served a tick in the current round are not eligible for another allocation before a new round has started, in which case the ambient’s name has “changed” to .

The reduction rules for virtually timed ambients are given in Tables 1 and 2. The rules in Table 1 (with rule names to the left) cover ambient reconfiguration. Apart from the annotations used for scheduling, the rules are exactly the ones from the (untimed) mobile ambients [5].

Table 1: Reduction rules (1).

Ambients can undergo restructuring in three different ways. First, an ambient can move horizontally or laterally by entering a sibling ambient (rule R-In). Second, it can move vertically up the tree, leaving its parent ambient (rule R-Out). Finally, a process can cause the dissolution of its surrounding ambient (rule R-Open). These forms of restructuring are timeless in that they incur no computation costs. If an ambient changes its place, the scheduler of the target ambient will from that point on, become responsible for the new ambient, and the treatment is simple: if frozen, the newcomer will not be served in the current round of the scheduler, but waits for the next round. Considering the source ambient (i.e., the ambient which contained the process executing the out or in capability), no process inside the source ambient looses or changes its status. A similar discipline is followed when opening an ambient in rule R-Open. Note that a process in an ambient can execute a capability in, out, or open independent of the status of the affected ambient, which is indicated in the rules by and .

To realize the round-based scheduling, processes conceptually switch back and forth between waiting to be served in the current round, and having been served and thus waiting for the next round to begin. The following definition of is used to mark a process as served:

Definition 3 (Freezing and unfreezing)

Let denote the process where all top-level occurrences of are replaced by and all top-level occurrences of c replaced by . Conversely, let denote the process where all top-level occurrences of are replaced by c and all top-level occurrences of replaced by . Define by induction on the syntactic structure as follows:

The definition of is analogous (e.g., ) and omitted here.

Remark that the congruence relation, which is part of the reduction semantics, works with scheduling in the sense that both operations defined in Def. 3 are preserved under congruence: implies and .

Table 2: Reduction rules (2)

Scheduling is covered by the reduction rules in Table 2, which details the handling of ticks and the resource capabilities. The first rule translates “incoming” ticks to ticks available for local processes. The translation ratio is uniform; i.e., one incoming tick produces one outgoing tick (this is the simplification compared to previous work mentioned earlier, where the ratio between incoming and local ticks could more generally be a rational number). A process can be consumed in two ways. First by scheduling a c-prefixed process which undergoes the steps (consuming in the second step). Second, by scheduling a subambient, such that an incoming tick occurs one level down in the hierarchy. To ensure the round-based scheduling, the scheduled entity must not have been served yet in the current round. For this purpose, the process before the transition must be of the form or , and after the transition the continuation of the process is frozen, using Def. 3. The last rule completes one scheduling round and initiates the next round by changing the ambient’s processes to . This unfreezing step can be done only if all the ambient’s processes have been served, which is captured be the negative premise stipulating that no process at the level of can proceed: at the given level, the processes are blocked, but that does not mean, that in subambients, all processes must be blocked as well.

Example 1

Consider the process . Three reduction steps are possible, as can propagate to either ambients and ambient can move into cloud. One way this process can reduce, is as follows:

However, the time slice could also enter the ambient vm, and move with this ambient, resulting in a reduction sequence starting as follows:

3 An Assumption-Commitment Type System

We consider a type system which analyzes the timed behavior of virtually timed ambients in terms of the movement and resource consumption of a given process. Statically estimating the timed behavior is complicated because the placement of an ambient in the process hierarchy influences its resource consumption, and movements inside the hierarchy changes the relative speed of the ambients. The proposed type system is loosely based on Cardelli, Ghelli, and Gordon’s movement control types for mobile ambients

[14]; however, its purpose is quite different, and therefore the technical formulation will be rather different as well.

Types, contexts, and judgments.

The typing of processes happens with respect to nominal resource contracts for virtually timed ambients. Contracts for ambients are tuples of the form

Here, specifies the ambient’s resource capacity, i.e., the upper bound on the number of resources that the subprocesses of the ambient are allowed to require; specifies the ambient’s hosting capacity, i.e., the upper bound on the number of timed subambients and timed processes allowed inside this ambient; and specifies the ambient’s currently hosted processes, i.e., the number of taken slots within the ambient’s hosting capacity. The number of currently hosted processes inside an ambient can change dynamically, due to the movements of ambients. These changes must be captured in the type system. In this sense, a type for ambient names contains an accumulated effect mapping.

Typing environments or contexts associate ambient names with resource contracts. They are finite lists of associations of the form . In the type system, when analyzing an ambient or process, a typing environment will play a role as an assumption, expressing requirements about the ambients outside the current process. Dually, facts about ambients which are part of the current process are captured in another typing environment which plays the role of a commitment. Notationally, we use for assumption and for commitment environments. We write for the empty environment, and for the extension of by a new binding . We assume that ambient names are unique in environments, so is not already bound in . Conversely, represents an environment coinciding with except that the binding for is removed. If is not declared in , the removal has no effect. The typing judgement for names is given as . Since each name occurs at most once, an environment can be seen as a finite mapping; we use to denote the ambient type associated with in and write for all names bound in . In the typing rules, the typing environment may need to capture the ambient in which the current process resides; this ambient will conventionally be denoted by the reserved name this.

Typing judgements for processes are of the form

where req and prov are the required and provided resources of a process , subs is the number of subambients of , and and are the assumptions and commitments of , respectively. We call req the coeffect of the process. Coeffects [8, 7] capture how a computation depends on an environment rather than how it affects this environment. We use the perspective of coeffects since a computation may require resources from its environment to terminate. Similarly, prov is the number of provided resources in ; these resources are available in independent of its environment, and subs approximates the number of subambients in . We may think of as the effect of the type judgment, where effects express what the process potentially provides to its environment.

Since ambient names are assumed to be unique, it follows for type judgments that , as an ambient is either inside the process and has its contract in the commitments, or outside and has its contract in the assumptions. Further, .

Definition 4 (Domain equivalence)

Two contexts and are domain equivalent, denoted , iff .

For each process, the domain of the assumptions is assumed to contain all names which are not in the domain of the commitments; i.e., for two parallel processes and such that and , we will have that , and .

Definition 5 (Additivity of contexts)

Let and be contexts such that , and for and . The context with domain is defined as follows:

If the number of currently hosted ambients is smaller than the hosting capacity of all ambients in an environment, we say that the environment is error-free:

Definition 6 (Error-free environments)

An environment is error-free, denoted if for all and .

Resource contracts can be ordered by their contents and environments by their resource contracts. The bottom type is a subtype of all resource contracts.

Definition 7 (Ordering of resource contracts and environments)

Let and be resource contracts. Then is a subtype of , written , if and only if , and . Typing environments are ordered by the subtype relation as follows: For type environments and , if and , for all .

Scheduling is reflected in the type rules by the calculation of the coeffect req. The coeffect captures the number of resources a process needs to terminate.

In Table 3, Rule T-Zero captures the inactive process, which does not require nor provide any time slices. Rule T-Tick1 expresses the availability of and Rule T-Tick2 that a time slice is ready to be consumed. Both judgements express that a time slice is provided without requiring any time slice. The assumption rule T-Ass types an ambient with the resource contract it has in the environment. The restriction rule T-Res removes the resource contract assumption in the environment for the restricted name. Subsumption relates different resource contracts, ; e.g., in subtypes (T-Tsub), the subsumption rule T-Sub allows a higher number of required resources, a lower number of provided resources and a higher number of subambients to be assumed in a process.

For the typing of ambients in Rule T-Amb, the number of resources a process requires changes if it becomes enclosed in an ambient ; i.e., we move to the resource contract of , provided the process satisfies its part of the contract. The contract here becomes a commitment whereas the required resources in the co-effect may be smaller than the bnd of the contract because may already have received the time slices prov.

The parallel composition rule T-Par makes use of the fairness of the scheduling of time slices in virtually timed ambients. While the branches agree on the required resources req, the provided resources and subambients accumulate. It follows from T-Par that several ambients in parallel will at most need as many resources req from the parent ambient as the slowest of them. Furthermore, T-Par changes assumptions and commitments depending on the assumptions and the commitments of the composed processes, using the context composition operator from Def. 5 to compose environments. We have , which is a consequence of the uniqueness of ambient names. The assumptions of the branches split the resource contracts of the environment between the type judgements for and and the commitments split such that is the assumption for and vice versa. For replication, the corresponding rule T-Rep imposes the restriction, that the process being replicated does not incur any cost; allowing that would amount to an unbounded resource need.

Table 3: Type rules for the virtually timed ambients.

Now consider the capability rules. In T-Consume, the resource consumption is a requirement to the environment, expressed by increasing the coeffect to . Since the process requires a time slice, it is counted among the currently hosted processes. If it was already counted as a timed process, subs remains unchanged, but since it could have been untimed, we let .

Rule T-In derives an assumption about ambient under which the movement can be typed. Since the movement involves all processes co-located with , the rule depends on the resource contract of this, the ambient in which the current process is located. The rule has a premise expressing that if can be typed with a resource contract for , then can be typed with the resource contract for . In addition, the hosting capacity of this and this itself are added to the assumed currently hosted processes tkn of the premise. The premise expresses that the required resources req must be within the resource capacity cap if scheduled to all processes within the hosting capacity bnd of . The effect and co-effect carry over directly from the premise, as the movement does not modify the required or provided resources or subambients of . In contrast, rules T-Open and T-Out simply preserve the co-effect and effect of its premise, since the actual movement is captured by the worst-case assumption in T-Amb.

Example 2 (Typing of in-capabilities)

We revisit Example 1 to illustrate the typing of . From T-Zero and T-Consume, we get . The -capability will move the ambient containing this process, which is captured by this in the typing environment. Let us type this by . In this case cloud will need a hosting capacity if at least , so let us type cloud by . Then, from T-In, we get

By T-Amb, we get . Similarly, and T-Par gives us

Example 3 (Typing of open-capabilities)

We consider the typing of a process . From T-Zero and T-Consume, we get . Let have type . Then, by T-Amb,

By T-Zero, T-Open and T Sub, we have . By T-Par, we obtain . Let cloud have type . By T-Amb, we get

Example 4 (Typing of out-capabilities)

We consider the typing of a process

By T-Zero and T-Consume, we have , and by T-Out we get

Let . We can type by

and, with , we get

Example 5 (Failure of type checking)

Type checking fails if the provisioning of resources for an incoming ambient in a timely way cannot be statically guaranteed. This can occur for different reasons. One reason is that an ambient may lack sufficient hosting capacity to take in the processes that want to enter. Let as before and consider again the process from Example 2. Now assume a second virtual machine which aims to enter the cloud ambient, resulting in the parallel process

We can type similarly to in Example 2.:

In contrast to Example 2, the hosting capacity for cloud in cannot accommodate both and ; type checking fails when giving cloud resource contract .

Another reason is that he resource contract of cloud may have a too low resource capacity. Consider a third virtual machine which can be typed with the resource contract for . Again, type checking fails if cloud were given the resource contract , since the resource capacity of cloud must here be at least with hosting capacity .

Example 6 (Capacity of an ambient)

Assume that the process

is well-typed. Let , and be resource contracts such that

for , and . Let and . Since is well-typed, we have and, by T-Par,

where , and . By applying T-Par again, we get

where , , and . Thus, the weakest resource contract which types and allows both and to enter, will have and .

4 Soundness of Resource Management

The soundness of resource management can be perceived similarly to that of message exchange [14]. We prove a subject reduction theorem, stating that the number of resources required to terminate a process is preserved under reduction.

Theorem 4.1 (Subject Reduction)

Assume and , then there are environments and such that and or .


By induction on the derivation of (For details, see Appendix 0.A).

Further, we prove a progress theorem, which shows that a well-typed process which receives the approximated number of resources from its environment will not get stuck because of missing resources. We use the contextual variant of barbing from Def. 2 to characterize a situation where inside the process, there is a sub-process in need of a tick to proceed, be it an unserved ambient or a process guarded by a -capability.

Theorem 4.2 (Tick progress)

Assume and let , where is running in parallel with req occurrences of inside some enclosing ambient. If for some context , then for some process .


This follows from the definition of the typing rules. If contains the subprocess it follows from the typing rule for the consume capability that . From the other typing rules it follows that req cannot be reduced to and the number of resources is sufficient to trigger the reduction . Thus, can reduce to and .

With the properties of subject reduction and progress the type system guarantees the soundness of resource management.

Corollary 1 (Soundness)

The type system guarantees the soundness of resource management, i.e., the transitive closure of the progress result holds.

5 Related Work

Gordon proposed a simple formalism for virtualization loosely based on mobile ambients [15]. The calculus of virtually timed ambients [4] stays closer to the syntax of the original ambient calculus, while including notions of time and resources. Our model of resources as processing capacity over time builds on deployment components [16, 17], a modelling abstraction for cloud computing in ABS [18]. Compared to virtually timed ambients, ABS does not support nested deployment components nor the timed capabilities of ambients. Timers have been studied for mobile ambients in [19]. In this line of work, timers, which are introduced to express the possibility of a timeout, are controlled by a global clock. In contrast, the schedulers in our work recursively trigger local schedulers in subambients which define the execution power of the nested virtually timed ambients. Modelling timeouts is a straightforward extension of our work. The calculus of virtually timed ambients presented here differs from earlier papers [4, 9] by assuming uniform time and by the use of freezing and unfreezing operations, which allow a significantly simpler formulation of the calculus. The behavior of the original calculus, with non-uniform time, can be recaptured by modifying the rule to cater for different numbers of input and output ticks, and to contextualize the rule for specific ambients. For the virtually timed ambients with non-uniform time, a modal logic with somewhere and sometime modalities has been developed [20] to express aspects of reachability for these ambients. Whereas this work can express more complex properties of a given process, the logic cannot express properties for all processes, in contrast to the contract-based type system presented in this paper.

A type system for the (originally untyped) ambient calculus was defined in [14]; this type system is mainly concerned with the use of groups to control communication and mobility. For communication, a basic type of an ambient captures the kind of messages that can be exchanged within. For mobility, the type system controls which ambients can enter. In a more traditional setting of sequential languages, types are often enriched with effects to capture the aspects of of computation which are not purely functional. In process algebra, session types have been used to capture communication in the -calculus. Orchard and Yoshida have shown that effects and session types are similar concepts as they can be expressed in terms of each other [21]. Session types have been defined for boxed ambients in [22] and behavioral effects for the ambient calculus in [23], where the original communication types by Cardelli and Gordon are enhanced by movement behavior. This is captured with traces, the flow-sensitivity hereby results from the copying of the capabilities in the type. Type-based resource control for resources in the form of locks has been proposed for process algebras in general [24] and for the -calculus in particular [25, 26].

The idea of assumptions and commitments (or relies and guarantees) is quite old, and has been explored in various settings, mainly for specification and compositional reasoning about concurrent or parallel processes (e.g., [27, 28, 29, 30, 31]). Assumption commitment style type systems have previously been used for multi-threaded concurrency [32, 33]; the resources controlled by the effect-type system there are locks and a general form of futures, in contrast to our work.

To capture how a computation depends on an environment instead of how the computation affects it, Petricek, Orchard and Mycroft suggest the term coeffect as a notion of context-dependent computation [8, 7]. Dual to effects, which can be modeled monadically, the semantics of coeffects is provided by indexed comonads [34, 35]. We use coeffects to control time and resources. An approach to control timing via types can be found in [36], which develops types and typed timers for the timed -calculus. Another approach to resource control without coeffects can be found in [37], which proposes a type system to restrict resource access for the distributed -calculus. In [38] a type system for resource control for a fragment of the mobile ambients is defined by adding capacity and weight to communication types for controlled ambients. Simplified non-modifiable mobile ambients with resources, and types to control migration and resource distribution are proposed in [39]. Another fragment of the ambient calculus, finite control ambients with only finite parallel composition, are covered in [40]. Here the types are a bound to the number of allowed active outputs in an ambient.

6 Concluding Remarks

Virtualization opens for new and interesting models of computation by explicitly emphasizing deployment and resource management. This paper introduces a type system based on resource contracts for virtually timed ambients, a calculus of hierarchical locations of execution with explicit resource provisioning. Resource provisioning in this calculus is based on virtual time, a local notion of time reminiscent of time slices provisioned by operating systems in the context of nested virtualization. The proposed assumption-commitment type system with effects and coeffects enables static checking of timing and resource constraints for ambients and gives an upper bound on the resources used by a process. The type system supports subsumption, which allows relating different types, e.g. weaker types, to each other. We show that the proposed type system is sound in terms of subject reduction and a progress properties. Although these are core properties for type systems, the results are here given for a non-standard assumption-commitment setting in an operational framework. The type system further provides reusable properties as it supports abstraction and the results would also hold for other operational accounts of fair scheduling strategies. The challenge of how to further generalize the distribution strategy and type system for, e.g., earliest deadline first or priority-based scheduling policies, remains.

The virtually timed ambients used for the models in this paper extend the basic ambient calculus without channel communication. Introducing channels would lead to additional synchronization, which could potentially be exploited to derive more precise estimations about resource consumption. Such an extension would be non-trivial as the analysis of the communication structure would interfere with scheduling.


  • [1] Goldberg, R.P.: Survey of virtual machine research. IEEE Computer 7(6) (1974) 34–45
  • [2] Ben-Yehuda, M., Day, M.D., Dubitzky, Z., Factor, M., Har’El, N., Gordon, A., Liguori, A., Wasserman, O., Yassour, B.: The Turtles project: Design and implementation of nested virtualization. In: Proceedings 9th USENIX Symposium on Operating Systems Design and Implementation (OSDI 2010), USENIX Association (2010) 423–436
  • [3] Williams, D., Jamjoom, H., Weatherspoon, H.: The Xen-Blanket: Virtualize once, run everywhere. In: Proceedings 7th European Conference on Computer Systems (EuroSys’12), ACM (2012) 113–126
  • [4] Johnsen, E.B., Steffen, M., Stumpf, J.B.: A calculus of virtually timed ambients. In James, P., Roggenbach, M., eds.: Postproceedings of the 23rd International Workshop on Algebraic Development Techniques (WADT 2016). Volume 10644 of Lecture Notes in Computer Science., Springer (2017) 88–103
  • [5] Cardelli, L., Gordon, A.D.: Mobile ambients. Theoretical Computer Science 240(1) (2000) 177–213
  • [6] Giovannetti, E.: Ambient calculi with types: a tutorial. In: Global Computing — Programming Environments, Languages, Security and Analysis of Systems. Volume 2874 of Lecture Notes in Computer Science., Springer (2003) 151–191
  • [7] Petricek, T., Orchard, D., Mycroft, A.: Coeffects: A calculus of context-dependent computation. In Jeuring, J., Chakravarty, M.M.T., eds.: Proceedings of the International Conference on Functional Programming (ICFP’14), ACM (2014)
  • [8] Petricek, T., Orchard, D., Mycroft, A.: Coeffects: unified static analysis of context-dependence. In Fomin, F.V., Freivalds, R., Kwiatkowska, M.Z., Peleg, D., eds.: Proceedings of the International Conference on Automata, Languages, and Programming (ICALP’13). Volume 7966 of Lecture Notes in Computer Science., Springer (2013) 385–397
  • [9] Johnsen, E.B., Steffen, M., Stumpf, J.B.: Virtually timed ambients: A calculus of nested virtualization. Journal of Logical and Algebraic Methods in Programming 94 (2018) 109 – 127
  • [10] Albert, E., Arenas, P., Genaim, S., Puebla, G., Zanardini, D.: Cost analysis of Java bytecode. In De Nicola, R., ed.: Proc. ESOP. Volume 4421 of Lecture Notes in Computer Science., Springer (2007) 157–172
  • [11] Albert, E., Correas, J., Johnsen, E.B., Pun, V.K.I., Román-Díez, G.: Parallel cost analysis. ACM Trans. Comput. Log. 19(4) (2018) 31:1–31:37
  • [12] Milner, R., Sangiorgi, D.: Barbed bisimulation. In Kuich, W., ed.: Proceedings of ICALP ’92. Volume 623 of Lecture Notes in Computer Science., Springer (1992) 685–695
  • [13] Merro, M., Zappa Nardelli, F.: Behavioral theory for mobile ambients. Journal of the ACM 52(6) (2005) 961–1023
  • [14] Cardelli, L., Ghelli, G., Gordon, A.D.: Types for the ambient calculus. Information and Computation 177(2) (2002) 160–194
  • [15] Gordon, A.D.: V for virtual. Electronic Notes in Theoretical Computer Science 162 (2006) 177–181
  • [16] Johnsen, E.B., Schlatte, R., Tapia Tarifa, S.L.: Integrating deployment architectures and resource consumption in timed object-oriented models. Journal of Logic and Algebraic Methods in Programming 84(1) (2015) 67–91
  • [17] Albert, E., de Boer, F.S., Hähnle, R., Johnsen, E.B., Schlatte, R., Tapia Tarifa, S.L., Wong, P.Y.H.: Formal modeling and analysis of resource management for cloud architectures: An industrial case study using Real-Time ABS. Journal of Service-Oriented Computing and Applications 8(4) (2014) 323–339
  • [18] Johnsen, E.B., Hähnle, R., Schäfer, J., Schlatte, R., Steffen, M.: ABS: A core language for abstract behavioral specification. In Aichernig, B., de Boer, F.S., Bonsangue, M.M., eds.: Proc. 9th International Symposium on Formal Methods for Components and Objects (FMCO 2010). Volume 6957 of Lecture Notes in Computer Science., Springer (2011) 142–164
  • [19] Aman, B., Ciobanu, G.: Mobile ambients with timers and types. In Jones, C.B., Liu, Z., Woodcock, J., eds.: Proceedings 4th International Colloquium on Theoretical Aspects of Computing (ICTAC’07). Volume 4711 of Lecture Notes in Computer Science., Springer (2007) 50–63
  • [20] Johnsen, E.B., Steffen, M., Stumpf, J.B., Tveito, L.: Checking modal contracts for virtually timed ambients. In Fischer, B., Uustalu, T., eds.: Proc. 15th Intl. Colloquium on Theoretical Aspects of Computing (ICTAC 2018). Volume 11187 of Lecture Notes in Computer Science., Springer (2018) 252–272
  • [21] Orchard, D., Yoshida, N.: Effects as sessions, sessions as effects. In: POPL 2016, ACM Press (2016)
  • [22] Garralda, P., Compagnoni, A., Dezani-Ciancaglini, M.: BASS: Boxed Ambients with Safe Sessions. In Maher, M., ed.: PPDP’06, ACM Press (2006) 61–72
  • [23] Amtoft, T.: Flow-sensitive type systems and the ambient calculus. Higher-Order and Symbolic Computation 21(4) (2008) 411–442
  • [24] Igarashi, A., Kobayashi, N.: Resource usage analysis. ACM Trans. Program. Lang. Syst. 27(2) (2005) 264–313
  • [25] Kobayashi, N., Suenaga, K., Wischik, L.: Resource usage analysis for the -calculus. Logical Methods in Computer Science 2(3) (2006)
  • [26] Kobayashi, N., Sangiorgi, D.: A hybrid type system for lock-freedom of mobile processes. ACM Trans. Program. Lang. Syst. 32(5) (2010) 16:1–16:49
  • [27] Abadi, M., Lamport, L.: Conjoining specifications. ACM Transactions on Programming Languages and Systems 17(3) (1995) 507–534
  • [28] Jones, C.B.: Tentative steps towards a development method for interfering programs. ACM Transactions on Programming Languages and Systems 5(4) (1983) 596–619
  • [29] Lamport, L.: Specifying concurrent program modules. ACM Transactions on Programming Languages and Systems 5(2) (1983) 190–222
  • [30] Misra, J., Chandy, K.M.: Proofs of networks of processes. IEEE Transactions on Software Engineering 7 (1981) 417–426
  • [31] Stark, E.W.: A proof technique for rely/guarantee properties. In Maheshwari, S.N., ed.: Foundations of Software Technology and Theoretical Computer Science. Volume 206 of Lecture Notes in Computer Science., Springer (1985) 369–391
  • [32] Ábrahám, E., Grabe, I., Grüner, A., Steffen, M.: Behavioral interface description of an object-oriented language with futures and promises. Journal of Logic and Algebraic Programming 78(7) (2009) 491–518
  • [33] Ábrahám, E., Grüner, A., Steffen, M.: Dynamic heap-abstraction for open, object-oriented systems with thread classes (extended abstract). In Beckmann, A., Berger, U., Löwe, B., Tucker, J.V., eds.: Logical Approaches to Computational Barriers: CiE 2006. Volume 3988 of Lecture Notes in Computer Science., Springer (July 2006) 1–10
  • [34] Katsumata, S.: Parametric effect monads and semantics of effect systems. In: Proceedings of POPL ’14, ACM (2014) 633–645
  • [35] Uustalu, T., Vene, V.: Comonadic notions of computation. Electronic Notes in Theoretical Computer Science 203 (2008) 263–284 Proceedings 9th Intl. Workshop on Coalgebraic Methods in Computer Science (CMCS 2008).
  • [36] Berger, M., Yoshida, N.: Timed, distributed, probabilistic, typed processes. In: Asian Symposium on Programming Languages and Systems, Springer (2007) 158–174
  • [37] Hennessy, M., Riely, J.: Resource access control in systems of mobile agents. Information and Computation 173(1) (2002) 82–120
  • [38] Teller, D., Zimmer, P., Hirschkoff, D.: Using ambients to control resources. In: Proceedings of the 13th International Conference on Concurrency Theory. CONCUR ’02, London, UK, Springer (2002) 288–303
  • [39] Godskesen, J.C., Hildebrandt, T., Sassone, V.: A calculus of mobile resources. In Brim, L., Křetínský, M., Kučera, A., Jančar, P., eds.: Proceedings 13th International Conference on Concurrency Theory (CONCUR 2002). Volume 2421 of Lecture Notes in Computer Science., Springer (2002) 272–287
  • [40] Charatonik, W., Gordon, A.D., Talbot, J.M.: Finite-control mobile ambients. In: European Symposium on Programming, Springer (2002) 295–313

Appendix 0.A Proof of Theorem 1

The proof proceeds by cases over the reduction rules of tables 1 and 2. In each case, we assume that the pre-state is well-typed and show that this assumption allows us to construct a type derivation for the post-state.

Case R-In.

Assume that is well-typed. Consequently, for some values cap and bnd we have types , and such that the following assumptions hold:
(1) , (2) and (3) .

It follows from Assumption 3 by T-Amb that

Let be typed by and let . It follows from Assumption 1 by T-In that

Let . Since , we know that . Let . From assumptions 1 and 2, we get from T-Par that


Let . Since , we get from T-Amb that

Let , , and . Then, by T-Par, we have

Now, we show that is well-typed. From Equation 1, we get , and by T-Amb

It follows by T-Par that

Let . By T-Amb, it follows that

Since , the case holds.

Case R-Out.

Assume that is well-typed. Consequently, the following assumptions hold: (1) , (2) and (3) .

From Assumption 1, by T-Out, we obtain . Let . It then follows from Assumption 2, by T-Par, that


Let . Then, by T-Amb, we obtain

Now, let , , and . We get from Assumption 3 using T-Par that

Let and . From T-Amb,

Now, we show that is well-typed. From Equation 2 and T-Out, we know that

and, by T-Amb, we obtain