12 Multiple Task Programming

Functions for Task Control

The TSTAT Function

TSTAT (taskid)

The TSTAT function returns the status of the specified task.

Summary of Image Symbols
Return Value Description
0Task is in idle state (that is, not in any of the other states).
1Task is in input state.
2Task is in wait state.
3Task is executing, but blocked for I/O.
4Task is in running state.

The OWNID Function

OWNID

The OWNID function returns the USRID of the owner of the executing task. A zero is returned if the executing task is unowned.

The XOWNID Function

The XOWNID function returns the USRID of a specified task. A zero is returned if it is a primary task or not REQUESTed

Example:

XOWNID (15)
returns the owner of TASK 15.

The SHOWTASK Function

The SHOWTASK function outputs information about eloquence tasks to the SYSTEM PRINTER.

TASK OWNER STAT UID   NAME      PID
---- ----- ---- ----- --------- -----
  12     0  0 Y   102 mike      27624
  15    12  0 N   102 mike      27625
  16    12  0 N   102 mike      27626
TASK:
Task number.
OWNER:
Owner if secondary task or 0.
STAT:
TSTAT of taskid and attached flag (Y=attached to terminal).
UID:
HP-UX user id.
NAME:
HP-UX user name.
PID:
eloqcore process id.

The SIGNAL statements

Eloquence can use the USR1 signal to communicate with either HP-UX processes or another Eloquence process.

ON SIGNAL
Branches to a specified program sequence when USR1 signal is caught
OFF SIGNAL
Cancels previous ON SIGNAL
SEND SIGNAL #
Send SIGUSR1 signal to specified taskid
The ON SIGNAL Statement

The ON SIGNAL statement sets up the branching condition which will occur if a USR1 signal is caught.

The branch occurs immediately after the current program line is executed.

Here is an example sequence which checks for the USR1 signal and branches to a routine to output some debug information.

100  ON SIGNAL GOSUB Signal
110  ON HALT GOTO Stop
120  LOOP
130   I=I+1
140  END LOOP
150 Stop:!
160  DISP "I=";I
170  END
180 Signal:!
190  DISP "I=";I
200  RETURN
The ON SIGNAL condition is cancelled after SCRATCH, STOP, END or RUN.

To cancel any previous ON SIGNAL condition, use the OFF SIGNAL statement:

   OFF SIGNAL
The SEND SIGNAL # Statement

The SEND SIGNAL # statement will send a USR1 signal to the specified taskid.

SEND SIGNAL #taskid

It is also possible to send USR1 signal from shell (or using the COMMAND statement) but this way you don't you have to know the process id of the destination process.

NOTE: The HP-UX protection scheme prohibits sending signals to a process of another user.


Eloquence Language Manual - 19 DEC 2002