The following is an example of how to call all the latch manager
services in C language:
/*********************************************************************/
/* C Example */
/*********************************************************************/
#pragma linkage(setsup, OS)
#pragma linkage(setprob, OS)
#include <ISGLMC.H> /* Include C language IDF */
main()
{
const int numberOfLatches = 16; /* in this example we create 16
latches */
ISGLM_LSNM_type latchSetName
= "EXAMPLE.ONE_LATCH_SET_NAME ";
/* set up 48-byte latch set name */
ISGLM_LSTK_type latchSetToken; /* latch set token - output from
create and input to obtain,
release, and purge */
int returnCode = 0; /* return code from services */
const int latchNumber = 6; /* in this example we obtain latch
six */
ISGLM_LRID_type requestorID = "123";/* requestor ID - output from
obtain and input to purge */
int ECB = 0; /* ECB used for latch obtain
service */
ISGLM_EADDR_type ECBaddress = &ECB;/* pointer to ECB */
ISGLM_LTK_type latchToken; /* latch token - output from
obtain and input to release */
union {
double alignment; /* force double word alignment */
ISGLM_WA_type area; /* set up work area */
} work;
setsup(); /* set supervisor state PSW */
/*********************************************************************/
/* create a latch set with 16 latches */
/*********************************************************************/
isglcrt(numberOfLatches
,latchSetName
,ISGLCRT_PRIVATE
,&latchSetToken;
,&returnCode);
/*********************************************************************/
/* obtain latch */
/*********************************************************************/
isglobt(latchSetToken
,latchNumber
,requestorID
,ISGLOBT_SYNC /* suspend until granted */
,ISGLOBT_EXCLUSIVE /* access option (exclusive) */
,&ECBaddress /* required, but not used */
,&latchToken /* identifies request */
,&work.area
,&returnCode);
/*********************************************************************/
/* release latch */
/*********************************************************************/
isglrel(latchSetToken
,latchToken
,ISGLREL_UNCOND /* ABEND if latch not owned */
,&workarea
,&returnCode);
/*********************************************************************/
/* purge requestor from latch set */
/*********************************************************************/
isglprg(latchSetToken
,requestorID
,&returnCode);
setprob(); /* set problem state PSW */
}
**********************************************************************
* SETSUP subroutine
**********************************************************************
SETSUP CSECT
SETSUP AMODE 31
SETSUP RMODE ANY
SAVE (14,12) save regs
SAC 0 ensure primary mode
LR 12,15 establish addressability
USING SETSUP,12
MODESET MODE=SUP set supervisor state
RETURN (14,12),RC=0 restore caller's regs and return
END SETSUP
**********************************************************************
* SETPROB subroutine
**********************************************************************
SETPROB CSECT
SETPROB AMODE 31
SETPROB RMODE ANY
SAVE (14,12) save regs
LR 12,15 establish addressability
USING SETPROB,12
MODESET MODE=PROB set problem state
RETURN (14,12),RC=0 restore caller's regs and return
END SETPROB