Previous Topic Next topic Print topic


CBL_SEMAPHORE_ACQUIRE

Acquires one of the resources represented by the semaphore by decrementing the associated count.
Restriction: This routine is not currently supported in COBOL for JVM.

Syntax:

call "CBL_SEMAPHORE_ACQUIRE" using by value semaphore-handle
                                   by value flags
                                  [by value timeout]

Parameters:

  Using call prototype (see Key) Picture
semaphore-handle cblt-pointer usage pointer
flags cblt-os-flags pic x(4) comp-5

or

pic x(8) comp-5 (64-bit native programs only)

timeout pic x(4) comp-5

On Entry:

semaphore-handle
Semaphore handle.
flags
A value that determines the action of the routine if the count is zero:
Bit 0
0 Block the thread/process until the count is non-zero, then the count is decremented and the call returns.
1

If no timeout is supplied (i.e. bit 1 = 0) then return immediately, no decrement

If timeout supplied (i.e. bit 1=1 ) then block until count is non-zero or timeout duration has expired. If the timeout expires, return error code 1010 ("no resources available"), else decrement count and return

Bit 1
0 No timeout parameter supplied
1 Timeout parameter is supplied and used if bit 0=1
Remaining bits
Reserved. Must be set to zero.
timeout
The timeout value in milliseconds. A value of zero returns immediately. This parameter is mandatory if bit 1=1 for the flags parameter; otherwise, it is optional.

On Exit:

return-code
A value of 0 indicates that the call was successful. Any other value indicates an error. See RETURN-CODE Values For Synchronization Routines

Comments:

Behavior is undefined if semaphore-handle is invalid.

Previous Topic Next topic Print topic