Addressing mode

A quantity resource has two fundamental modes of operation specified by the Addressing Mode resource attribute. The default value is NonIndexed, which makes resource units indistinguishable from one another. Resource units are viewed simply as tokens. The other possible setting for this attribute is Indexed. In this mode, each unit of the resource is assigned an integer index, beginning with zero. The status of each resource unit is maintained and can be either in use (not in the pool) or idle (in the pool). A request for resource units is then a request for a contiguous block of resource units. An integer vector, called the Indexed Usage Vector, is maintained to store the state of each resource unit. In this vector, a 1 indicates that a particular resource unit is in use, while a 0 means that the resource unit is not in use.

Uses of the indexed addressing mode

The indexed addressing mode is useful in a model where the resource units represent items that are distinguishable. For instance, if the resource represents pages of memory and transactions need contiguous pages of memory, the indexed addressing mode is appropriate.

Another use of a quantity resource with indexed addressing mode would be for allocation of virtual circuit numbers in a network. In this case, requests always ask for a single resource unit, and the index of that unit is the virtual circuit number that can be used.


When you use the indexed addressing mode, one of the outputs of the Allocate block is the starting index for the resource units. Store this value (usually in a field of your data structure) and pass it to the Free block when you release the resource units. The Free block must be told the number of units to be freed and the starting index of those units if the addressing mode is indexed.

MLDesigner does not limit the number of resource units that can be represented with an indexed quantity resource. Remember that the state of every resource unit is kept with an integer vector having one element for each resource unit, so simulating an indexed resource with a large number of resource units takes longer to execute than if the addressing mode is NonIndexed.