Download Print this page

IBM 4300 Manual page 105

Processors principles of operation for ecps: vse mode
Hide thumbs Also See for 4300:

Advertisement

Program Exceptions:
Access (fetch and store, operand 2)
Specification
Programming Notes
1. Several examples of the use of the COMPARE
AND SWAP and COMPARE DOUBLE AND
SWAP instructions are given in Appendix A.
2. The instruction CS can be used by programs
sharing common storage areas in either a
multiprogramming or multiprocessing.
environment. Two examples are:
a.
By performing the following procedure, a
program 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 CPU may simultaneously
update 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
instruction CS is executed with the R
1
field
designating the register that contains the
original value and the R3 field designating
the register that contains the updated value.
If
condition code 0 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
successful, and the general register
designated by the R
1
field of the CS
instruction contains the new current value
of the storage location. When condition
code 1 is set, the program can repeat the
procedure using the new current value.
b. The instruction CS can be. used for
controlled sharing of a common storage
area in a manner similar to that described
in the programming note under TEST AND
SET, but it provides the added capability of
leaving a message when the common area is
in use. To· accomplish this, a word in
storage can 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 of the most recent message
added to the list. Thus, any number of
7-12
IBM 4300 Processors Principles of Operation
programs. desiring to seize the area can use
CS to update 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 can also safely use CS to
remove messages from the list.
3. The instruction CDS can be used in a manner
similar to that described for CS. In addition, it
has another use. Consider a chained list, with
a control word used to address the first message
in the list, as described in programming note 2b
above.
If
multiple programs are permitted to
add and delete messages by using CS, there is a
possibility the list will be incorrectly updated.
This would occur if, after one program has
fetched the address of the most recent message
in order to remove the message, another
program removes the first two messages and
then adds the first message back into the chain.
The first program, on continuing, cannot easily
detect that the list is changed. By increasing
the size of the control word to a double word
containing both the first message address and a
word with a change number that is incremented
for each modification of the list, and by using
CDS to update both fields together, the
possibility of the list being incorrectly updated
is reduced to a negligible level. That is, an
incorrect update can occur only if the first
program is delayed while changes exactly equal
in number to a multiple of 2 32 take place and
only if the last change places the original
message address in the control word.
4. The instructions CS and CDS do not interlock
against storage accesses by channels.
Therefore, the instructions should not be used
to update a location which is in an 110 input
area, since the input data may be ·lost.
5. For the case of a condition-code setting of 1,
the instructions CS and CDS mayor may not,
depending on the model, cause any of the
following to occur for the second-operand
location: a PER storage-alteration event may
be recognized; a protection exception for
storing may be recognized; and, provided no
access exception exists, the change bit may be
turned on.

Advertisement

loading