Library Task Attributes

Task Attributes for Entered Procedures

If a process enters an imported procedure, the task attributes of the importing process govern the execution of the procedure. If the MYSELF predeclared task variable is used in the imported procedure, MYSELF refers to the importing process. If the MYJOB task variable is used in the imported procedure, MYJOB refers to the job of the importing process (that is, the eldest ancestor of the importing process).

Task Attributes for Initiated Procedures

If a process initiates an imported procedure, the resulting process receives its own set of task attributes. In this case, the MYSELF task variable refers to the new process. The MYJOB task variable refers to the job of the importing process and the new process. (Because the new process must be dependent, the client process and the new process always have the same job.)

Access to Task Attributes of the Library

Thus, the MYSELF task variable, when referenced in an imported procedure, never refers to the task attributes of the library process that exported the procedure. There is no direct way for the importing process to access the task attributes of the library process it is linked to.

On the other hand, you can design a library to provide importing processes with indirect access to the task variable of the library process. The following ALGOL server library program provides indirect access to its own task variable:

BEGIN

PROCEDURE VIRTUAL_OB (LIBTASK);
   TASK LIBTASK;
   BEGIN
   PROCEDURE X (I);
      INTEGER I;
      BEGIN
        I := LIBTASK.TASKVALUE;
        END;
      EXPORT X;
      FREEZE(TEMPORARY);
      END;

VIRTUAL_OB (MYSELF);

END.

In the preceding example, the exported procedure X indirectly interrogates a task attribute of the library's task variable. This indirect access is possible because the library program passes MYSELF as an actual parameter to the formal parameter LIBTASK of procedure VIRTUAL_OB. Because exported procedure X is declared in VIRTUAL_OB, procedure X has access to the LIBTASK variable.

APPROVAL and CHANGE Procedures

The MYSELF task variable should not be used inside APPROVAL procedures or CHANGE procedures. For further information, refer to the APPROVAL and CHANGE headings earlier in this section.

Task Attributes Useful for Libraries

Certain task attributes are particularly useful in the implementation of library applications. These include the following:

  • LIBRARY

    This attribute passes library equations to a client process at run time. A library equation modifies the library attributes of libraries declared in the client process. Each library equation is applied to the library declaration with the corresponding internal name, as discussed under INTNAME earlier in this section.

  • LIBRARYSTATE

    This attribute reports several types of information about a library process, including the sharing value, the type of freeze, and the linkage class. A library process also uses this attribute to determine whether the library process was initiated through the library linkage mechanism.

  • LIBRARYUSERS

    For a server library process, this attribute returns the total number of client processes or connection libraries that are linked to this server library.

  • STATUS

    A frozen server library process can be thawed by assigning this task attribute the value of GOINGAWAY, as discussed in Monitoring and Controlling Process Status. In addition, the GOINGAWAY assignment prevents further client processes from linking to this library instance.