unlock()
Release a PSL process lock.
Syntax
Parameter
Parameter | Definition |
---|---|
lockname | name of the lock that should be released |
Description
The unlock() function releases lockname that was granted to this process by a previous call to the lock() function. The unlock() function returns 1 for success and 0 for failure. If no lock is named lockname or if it is not currently owned by this process, then the unlock() function reports a run-time error, sets the PSL errno variable, and returns 0.
If this process is the only one holding the lock and processes are queued for it, the first waiting process is awakened and granted use of the lock. If the first process is a shared request, then any other processes that are queued for a shared lock are also granted shared access to the lock (except for processes that are behind a writer request on the queue for this lock).
Example
The following is an example of the unlock() function:
printf("lock released\n”);
} else {
printf("lock release failed\n”);
}