sema_trywait(SYNCH)
sema_trywait --
conditionally claim resources under the semaphore's control
Synopsis
cc [options] -Kthread file
#include <synch.h>
int sema_trywait(sema_t *sema);
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.
Parameters
sema-
pointer to the semaphore to acquire
sema parameter
sema must have been previously initialized,
either by sema_init or statically (see sema_init(SYNCH)).
Usage
sema_trywait is used when the caller does not want to block
if the semaphore is unavailable.
Return values
sema_trywait returns zero for success
and an error number for failure.
Errors
If the following condition occurs,
sema_trywait fails and returns the corresponding value:
EBUSY-
the semaphore cannot be acquired immediately
If the following condition is detected,
sema_trywait returns the corresponding value:
EINVAL-
invalid argument specified
References
Intro(SYNCH),
semaphore(SYNCH),
sema_destroy(SYNCH),
sema_init(SYNCH),
sema_post(SYNCH),
sema_wait(SYNCH)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005