o First and second operands equal, second
1 First and second operands unequal, first oper
and replaced by second operand
2 -
3
Operation (if the conditional-swapping feature is
not installed)
Programming Notes
The instruction
used by programs sharing common storage areas in
either a multiprogramming or multiprocessing envi
ronment. The following are two examples:
By performing the following procedure, a pro
gram can modify the contents of a storage location
even though the possibility exists that the program
may be interrupted by another program that will
update the location or even though the possibility
exists that another
the location. First, the entire word containing the
byte or bytes to be updated is loaded into a general
register. Next, the updated value is computed and
placed in another general register. Then the instruc
tion
Rl field designating the register that contains the
original
ter that contains the updated value. If condition code
o is set, the update has been successful. If condition
code 1 is set, the storage location no longer contains
the original value, the update has not been success
ful, and the general register designated by the Rl
field of the
contains the new current value of the storage loca
tion. When condition code 1 is set, the program can
repeat
trolled sharing of a common storage area in a man
ner similar to that described in the programming
note unde:r TEST AND SET, but it provides the
added capability of leaving a message when the com
mon area is in use. To accomplish this, a word in
storage may be used as a control word, with a zero
value in the word indicating that the common area is
not in use, a negative value indicating that the area is
in use, and a nonzero positive value indicating that
the common area is in use and that the value is the
address
Thus, any number of programs desiring to seize the
124
the control word to indicate that the area is in use or
to add messages to the list. The single program
which has seized the area may also safely use
list.
It should be noted that
nels. Therefore, the instruction should not be used to
update a word, all or part of which is in an
area, since the input data may be lost.
Compare Double and Swap
CDS [RS]
BB
o 8 12 16 20 31
The first and second operands are compared. If they
are equal, the third operand is stored in the second
operand location. If they are unequal, the second
operand is loaded into the first-operand location.
The first and third operands are 64 bits in length,
with each operand occupying an even-odd pair of
general registers. The second operand is a double
word in main storage.
The result of the 64-bit comparison, either equal
or unequal, is used to set the condition code. When
the result of the comparison is unequal, no attempt
to store occurs, and no change-bit and store-
protection actions are taken. .
When an equal comparison occurs, no access by
another
location between the moment that the second oper
and is fetched for comparison and the moment that
the third operand is stored at the second-operand
location.
A serialization function is performed before the
operand is fetched, and, if condition code
after the result is stored.
until all previous accesses by this
age have been completed, as observed by channels
and other
fetched. No subsequent instructions or their oper
ands are accessed by this
is completed, including placing the result value, if
any, in main storage, as observed by channels and
other
register, and the second operand must be designated
suppressed.