contentions, either in a LIFO or FIFO
manner. The lock/unlock functions can
then be used as the interlock mechanism
for updating an SRR of any complexity.
The lock/unlock functions are based on
the use of a "header" associated with
the SRR. The header is the common
starting point for determining the
states of the SRR, either free or in
use, and also is used for queuing
requests when contentions occur. Contentions are resolved using WAIT and POST. The general programming technique
requires that the program that encount­
ers a "locked" SRR must "leave a mark on
the wall" indicating the address of an ECB on which it will WAIT. The "unlock­ ing" program sees the mark and posts the ECB, thus permitting the waiting program
to continue. In the two examples given,
all programs using a particular SRR must
use either the LIFO queuing scheme or
the FIFO scheme; the two cannot be
mixed. When more complex queuing is
required, it is suggested that the queue
for the SRR be locked using one of the
two methods shown. LOCK/UNLOCK with LIFO Queuing for Contentions The header consists of a word, that is, a four-byte field aligned on a word
boundary. The word can contain zero, a
positive value, or a negative value.
A zero value indicates that the
serially reusable resource (SRR) is
free.
A negative value indicates that the
SRR is in use but no additional
programs are waiting for the SRR.
A positive value indicates that the
SRR is in use and that one or more
additional programs are waiting for
the SRR. Each waiting program is
identified by an element in a
chained list. The positive value
in the header is the address of the
element most recently added to the
list.
Each element consists of two words. The
first word is used as an ECB; the second
word is used as a pointer to the next
element in the list. A negative value
in a pointer indicates that the element
is the last element in the list. The
element is required only if the program
finds the SRR locked and desires to be
placed in the list.
The following chart describes the action
taken for LIFO LOCK and LIFO UNLOCK routines. The routines following the
chart allow enabled code to perform the
actions described in the chart.
Appendix A. Number Representation and Instruction-Use Examples A-43
Action Header Contains Header Contains Header Contains Function Zero Positive Value Negative Value LIFO LOCK SRR i s free. SRR is in use. Store the
(the incoming Set the header contents of the header into element is at to a negative location A+4. Store address A
location A) value. Use the into the header. WAIT; the ECB SRR. is at location A. LIFO UNLOCK Error Some program is The list is
waiting for the empty. Store
SRR. Move the zeros into the
pointer from header. The SRR
the "last in" is free.
element into
the header. POST; the ECB is in the "last in" element. LIFO LOCK Routine:
Initial Conditions: GRI contains the address of the incom­
ing element. GR2 contains the address of the header. LLOCK SR
ST LNR 3,3 3,0(1) 0,1 GR3 = 0 Initialize the ECB GRO = a negative
value
TRYAGN CS 3,0,0(2) Set the header to
a negative value
if the header
USE BC ST CS LA BC 8,USE
3,4(1)
contains zeros
Did the header
contain zeros? No, store the
value of the
header into the
pointer in the
incoming element 3,1,0(2) Store the address
of the incoming element into the
header 3,0(0) GR3 = 0 7,TRYAGN Did the header get
updated?
WAIT ECB=(1) Yes, wait for the
resource; the ECB is in the
incoming element
[Any instruction] LIFO UNLOCK Routine:
Initial Conditions: GR2 contains the address of the header.
A-44 System/370 Principles of Operation LUNlK L
A LTR BC L CS BC 1,0(2) 1,1
4,B 0,4(1) 1,0,0(2) 7,A
GR1 = the contents
of the header
Does the header
contain a neg­
ative value?
No, load the
pointer from the "last in" element
and store it in
the header
Did the header get
updated? POST (1) Yes, post the "last in" element Continue B
EXIT BC SR CS BC [Any
15,EXIT 0,0 1,0,0(2) The header contains a negative value;
free the header
7,A and continue
instruction]
Note that the LOAD instruction L 1,0(2) at location LUNLK would have to be CS 1,1,0(2) if it were not for the rule
concerning storage-operand consistency.
This rule requires the LOAD instruction
to fetch a four-byte operand aligned on
a word boundary such that, if another CPU changes the word being fetched by an
operation which is also at least word­
consistent, either the entire new or the
entire old value of the word is
obtained, and not a combination of the
two. (See the section "Storage-Operand Consistency" in Chapter 5, "Program Execution.") LOCK/UNLOCK with FIFO Queuing for Contentions The header always contains the address
of the most recently entered element.
The header is originally initialized to
contain the address of a posted ECB. Each program using the serially reusable
resource (SRR) must provide an element
regardless of whether contention occurs.
Previous Page Next Page