## The `upc_lock_attempt` function

#### Synopsis

        #include <upc.h>
        int upc_lock_attempt(upc_lock_t *ptr);

#### Description

The `upc_lock_attempt` function attempts to set the state of the lock pointed to by `ptr` to locked.

If the lock is already in locked state due to the calling thread setting it to locked state, the result is undefined.

If the lock is already in locked state the function returns 0.

If the lock is in state unlocked, a single calling thread sets the state to locked and the function returns 1.

A null strict access is implied after a call to upc_lock_attempt() that returns 1.

Terms, definitions, and symbols

Back to index of all UPC functions