a0TryPSemaphore()

Tries to perform a P on a semaphore.


Syntax

a0tError a0TryPSemaphore(
a0tSemaphore *semaphore
int *succeed );

Arguments

Namerd/wrDescription
semaphore write Semaphore descriptor to operate.
succeed write Flag true if a P was possible.

Description

This routine tests if the counter associated with the semaphore is zero or negative and returns the result in succeed. The thread doesn't block, but when succeed is true the counter is decremented, as if a real P operation had succeeded.


Return Values

If an error condition occurs, it returns the error code, otherwise it returns A0ErrOk. Possible values are as follows:
Error CodeDescription
A0Err...Some error occurred.
A0ErrOkSuccessful completion.

See Also

a0NewSemaphore() a0DisposeSemaphore() a0PSemaphore() a0VSemaphore()