BPX4SCT (semctl) example

The following code retrieves the PID of the last process toupdate semaphore 4 from the SEM_ID semaphore set. For the callable service, see semctl (BPX1SCT, BPX4SCT) — Perform semaphore control operations. For the data structure, see BPXYSEM — Map interprocess communication semaphores. AMODE 31 callers use BPX1SCT (semctl) example.
                                              
         LA    R15,BUFFERA                                              
         STG   R15,BUFA                                                 
         MVC   SEM_NUMBER(4),4       Semaphore number 4 in set          
         SPACE ,                                                        
         CALL  BPX4SCT,              Semaphore control operations      +
               (SEM_ID,              Input: Semaphore set ID           +
               SEM_NUMBER,           Input: Semaphore number (0 based) +
               =A(SEM_GETPID),       Input: Action to take     BPXYSEM +
               BUFA,                 Input: Value | Buffer | Array | 0 +
               RETVAL,               Return value: 0, -1 or value      +
               RETCODE,              Return code                       +
               RSNCODE),             Reason code                       +
               MF=(E,PLIST)          ----------------------------------