Prism 6.0 User's Guide

Syntax for Defining a Pset

This section describes the syntax you can use to specify a pset. As described below, you can assign a name to a pset you specify using this syntax; this provides a useful shorthand for complicated pset specifications.

First, to specify a pset as an argument to a command:

To apply a command to a specific pset, use the pset keyword, followed by a process specification. Put this pset clause at the end of the command line (but before an on window clause, if any). Thus,

print x pset error

prints the values of the variable x in the predefined pset error. (See " Visualizing Multiple Processes in MP Prism" for a discussion of printing variables in MP Prism.)

To specify your own pset as part of this pset clause:

Specify an individual process number. An individual process can constitute a pset. Thus,

print x pset 0

prints the value of x in process 0.

Specify the name of a pset. Name a pset using the define pset command, as described in the section "Naming Psets," below. Thus,

print x pset foo

prints x in the processes you have defined to be members of pset foo.

Specify a list of process numbers. Separate the numbers with commas. Thus,

print x pset 0, 4, 7

prints x in processes 0, 4, and 7.

Ranges and strides are allowed. Use a colon between two process numbers to indicate a range. Use a second colon to indicate the stride to be used within this range. Thus,

print x pset 0:10

prints x in processes 0 through 10. And

print x pset 0:10:2

prints x in processes 0, 2, 4, 6, 8, and 10.

You can also combine comma-separated process numbers and range specifications. For example,

print x pset 0, 1, 3:5, 8

prints x in processes 0, 1, 3, 4, 5, and 8.

Specify a union, difference, or intersection of psets. To specify the union of two psets, use the symbol +, |, or ||. For example,

print x pset 0:2 + 8:10

prints x in processes 0, 1, 2, 8, 9, and 10.

print x pset foo | bar

prints x in processes that are members of either pset foo or pset bar.

Prism evaluates the pset expression from left to right. If a process returns true for the first part of the expression, it is not evaluated further. In the above example, if a process is a member of foo, its value of x is printed; Prism does not check its membership in bar.

Use a minus sign to specify the difference of two psets. For example,

print x pset stopped - foo

prints x in all processes that are stopped except those belonging to the pset foo.

To specify the intersection of two psets, use the &, &&, or * symbol. For example,

print x pset foo & bar

prints x in processes that are members of both pset foo and pset bar. If a process returns false for the first part of the expression, it is not evaluated further. In the above example, if a process is not a member of foo, Prism doesn't bother checking its membership in bar; it won't be printed in any case.

Prism must evaluate a pset expression in each process at the time the command is executed; the processes must be stopped for Prism to do this. The evaluation fails if any of the processes being evaluated are running. Using the predefined pset stopped on the left of an intersection expression is a useful way of ensuring that a command applies only to stopped processes.

Thus,

print x pset stopped & foo

prints x only in the members of foo that are stopped.

Specify a condition to be met. Put braces around an expression that evaluates to true or false in each process. Processes in which the expression is true are part of the set.

Thus,

print x pset { y > 1 }

prints x in processes where y is greater than 1. And

print x pset all - { y == 1 }

prints x in all processes except those in which y is equal to 1.

Membership in a set defined with this syntax can change based on the current state of your program; such a pset is referred to as variable. See " Evaluating Variable Psets " to learn how to update the membership of a variable pset.

For this syntax to work, the variable must be active in all processes in which the expression is evaluated. If the variable isn't active in a process, you get an error message and the command is not executed. To ensure that the command is executed, use the intrinsic isactive in the pset definition. The expression isactive(variable) returns true if variable is on the stack for a process or is a global.

Thus, you could use this syntax to ensure that x is printed:

print x pset stopped && {isactive(x)}