<<

Contents

Search

>>

 

ADD_SYNCHRONIZED

 

 

Function

 

 

Syntax:

ADD_SYNCHRONIZED(<Number of Variable>,<Area From>,<Area To>,<Increment By>)

 

<Number of Variable>

= <NUM-EXPRESSION>

<Area From>

= <NUM-EXPRESSION>

<Area To>

= <NUM-EXPRESSION>

<Increment By>

= <NUM-EXPRESSION>

 

 

Meaning:

Under Java there are macros which are started via a timer, as separate thread parallel to the current processing. File accesses and accesses to commonly used variables must therefore be synchronized.

 

The functions SET_SYNCHRONIZED and ADD_SYNCHRONIZED make 10 integer variables (<Number of Variable> = 0,...,9) available, by which the synchronisation can be carried out. All variables are set to 0 at the start of the program.

 

The function ADD_SYNCHRONIZED checks whether the value of the variable <Number of Variable> lies in the area between <Area From> and <Area To> (<Area From> <= number of variable <= <Area To>). If yes, <Increment By> is added to the value of the variable and the function returns the result 1.

 

If the value of the variable <Number of variable> does not lie in the area between <Area From> and <Area To>, the value of the variable is not changed and ADD_SYNCHRONIZED returns the result -1.

 

If <Number of Variable> < 0 or > 9, ADD_SYNCHRONIZED returns the result -2. 

 

<Number of Variable>, <Area From>, <Area To> and <ADD> must contain integer numbers.

 

ADD_SYNCHRONIZED is 'thread safe'. This means that only one thread may access the variables and thus the value of the variables is always well defined.

 

Parameter:

Number of Variable

Number of Variable(0,...9)

Area From

Minimum value

Area To

Maximum value

Increment By

Increment value (may be negative)

 

Sample:

ON TIMER MACRO READ.DATE

...

Macro READ.DATE:

/* check if variable 2 has value 0 or 1.

/* If yes, increment value by 5.

IF ADD_SYNCHRONIZED(2,0,1,5) = -1

THEN /*... access not possible

ELSE ... read appointment from file APPOINTMENTS

         /* reduce value of variable by 5 again

        IF ADD_SYNCHRONIZED(2,5,6,-5) = -1

        THEN /* Resetting is not possible. There must then be

             /* a programming error, since another

             /* thread has in the meantime set the variable to 

             /* another value.

        ENDIF

ENDIF

 

See also:

SET_SYNCHRONIZED

SYNCHRONIZED

START_THREAD