TS/MP Pathsend and Server Programming Manual (G06.24+, H06.03+)
Examples
NonStop TS/MP Pathsend and Server Programming Manual–132500
B-25
Pathsend Requester Example
?PAGE "ALLOCATE A NEW CONTROL BLOCK FROM THE MEMORY POOL"
! This proc gets memory from the pool for a new control block (cb).
! The caller passes in the head of a list of control blocks, and it
! links the new cb to the end of that list.
! If the list head has a nil address, then the new cb becomes the
! first element of the list.
! This proc returns the address of the new control block. Before
! returning, the new cb is zero'd.
DBL PROC get^control^block (cb^list^head);
INT .EXT cb^list^head (control^block^template);
BEGIN
INT .EXT cb (control^block^template) := @cb^list^head;
INT .EXT new^cb (control^block^template);
INT .buf [0:79];
STR .sbuf := @buf '<<' 1;
STR .sp;
@new^cb := GETPOOL (PoolHead, $UDBL ($LEN (cb)));
IF @new^cb = -1D
THEN ! couldn't get memory
BEGIN
sbuf ':=' "GETPOOL FAILED TO GET MEMORY IN GET^CONTROL^BLOCK" -> @sp;
CALL WRITE (error^log^fnum, buf, @sp '-' @sbuf);
IF <
THEN ! print an error msg and abend
CALL IO^error (error^log^fnum);
CALL ABEND;
END;
! If the caller passed in a list head with nil address, then make
! the new cb the first element in the list.
IF @cb = nil^addr
THEN ! the user passed an empty list
@cb := @new^cb
ELSE ! link the new cb to the end of the list
BEGIN
WHILE @cb.next^cb <> nil^addr DO
@cb := @cb.next^cb;
@cb.next^cb := @new^cb;
@cb := @cb.next^cb;
END;