next up previous
Next: Global array Up: Global variables Previous: Global variables

Global scalar and data owner

The following code,

  on(p)
    int # s = new int #;

creates a global scalar on the current executing process group. In the statement, s is a data descriptor handle, in HPJava term, a global scalar reference. And the scalar is of an integer value. Global scalar references can be defined for each primitive type and class type in Java.

The symbol # in the right hand side of the assignment indicates a data descriptor is allocated as the scalar is created. Also it will be used to access this int value, as in the following, 3

  on(p) {
    int # s = new int #;
    # s = 100;
  }

Figure 3 shows a possible memory mapping for this scalar on different processes.

Figure 3: Memory mapping
\begin{figure}\begin{center}
\leavevmode
\psfig{figure=map.eps} \end{center}\end{figure}

Note, the value of s is duplicated on each process in the current executing processes. Duplicated variables are different from replicated local variables. The descriptors they have can be used to keep their value identical on each process during the program execution.

Compared with a local variable,

  on(p)
    int t = 10;

the memory layout for the two will be quite different. There is no data descriptor allocated with t, neither t is a handle.

The group inside a descriptor is called data owner group, it defines where the global variable belongs.

For a local variable, the data owner is the process which holds the data, though there is no descriptor to record it. For example, there will be an integer t on each process in Group p when t is defined as above.

For a global variable, the data owner group and the group on which the data are defined are two different concepts. By default, the data owner is the current executing group. We can also specify the data owner group explicitly by using an optional on clause after new operator.

  on(p)
    int # s = new int # on q;

will set data owner field in the descriptor of s as Group q.

Note, the on clause only change the data owner, it does not change the scope of the variable. The above code is similar but different from the following one.

  on(q) 
    int # s = new int #;

In the previous fragment, the owner of s is set as Group q, but its descriptor is duplicated on each process in Group p where s is defined.


next up previous
Next: Global array Up: Global variables Previous: Global variables
Bryan Carpenter 2002-07-12