sema_trywait(3synch) sema_trywait(3synch)
NAME
sema_trywait - conditionally claim resources under the
semaphore's control
SYNOPSIS
cc [options] -Kthread file
#include <synch.h>
int sema_trywait(sema_t *sema);
Parameters
sema pointer to the semaphore to acquire
DESCRIPTION
sema_trywait makes a single attempt to acquire the semaphore
pointed to by sema. If the semaphore is available,
sema_trywait decrements the semaphore value and returns to the
caller.
If sema_trywait cannot immediately acquire the semaphore, it
returns EBUSY to the caller, it does not block the caller to
wait for the semaphore or decrement the semaphore value.
sema Parameter
sema must have been previously initialized, either by
sema_init or statically (see sema_init).
Return Values
sema_trywait returns zero for success and an error number for
failure, as described below.
Errors
If any of the following conditions occurs, sema_trywait fails
and returns the corresponding value:
EBUSY The semaphore cannot be acquired immediately
If any of the following conditions is detected, sema_trywait
returns the corresponding value:
EINVAL Invalid argument specified.
USAGE
sema_trywait is used when the caller does not want to block if
the semaphore is unavailable.
Copyright 1994 Novell, Inc. Page 1
sema_trywait(3synch) sema_trywait(3synch)
REFERENCES
semaphore(3synch), sema_destroy(3synch), sema_init(3synch),
sema_post(3synch), sema_wait(3synch), synch(3synch)
Copyright 1994 Novell, Inc. Page 2