Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sem_getvalue(3) [osf1 man page]

sem_getvalue(3) 					     Library Functions Manual						   sem_getvalue(3)

NAME
sem_getvalue - Gets the value of a specified semaphore (P1003.1b) LIBRARY
Realtime Library (librt.so, librt.a) SYNOPSIS
#include <semaphore.h> int sem_getvalue ( sem_t *sem, int *sval); PARAMETERS
sem Specifies a pointer to the semaphore for which a value is to be returned. sval References a location to be updated with the value of the semaphore indicated by the sem argument. DESCRIPTION
The sem_getvalue function updates a location referenced by the sval argument with the value of semaphore sem. The updated value represents an actual semaphore value that occurred during the call, but may not be the actual value of the semaphore at the time that the value is returned to the calling process. If the semaphore is locked, the value returned will either be zero or a negative number indicating the number of processes waiting for the semaphore at some time during the call. RETURN VALUES
On a successful call, a value of 0 (zero) is returned. Otherwise, a value of -1 is returned and errno is set to indicate that an error occurred. ERRORS
The sem_getvalue function fails under the following condition: [EINVAL] The sem argument does not refer to a valid semaphore. RELATED INFORMATION
Functions: sem_post(3), sem_trywait(3), sem_wait(3) Guide to Realtime Programming delim off sem_getvalue(3)

Check Out this Related Man Page

sem_getvalue(3RT)					    Realtime Library Functions						 sem_getvalue(3RT)

NAME
sem_getvalue - get the value of a semaphore SYNOPSIS
cc [ flag... ] file... -lrt [ library... ] #include <semaphore.h> int sem_getvalue(sem_t *restrict sem, int *restrict sval); DESCRIPTION
The sem_getvalue() function updates the location referenced by the sval argument to have the value of the semaphore referenced by sem with- out affecting the state of the semaphore. The updated value represents an actual semaphore value that occurred at some unspecified time during the call, but it need not be the actual value of the semaphore when it is returned to the calling process. If sem is locked, then the value returned by sem_getvalue() is either zero or a negative number whose absolute value represents the number of processes waiting for the semaphore at some unspecified time during the call. The value set in sval may be 0 or positive. If sval is 0, there may be other processes (or LWPs or threads) waiting for the semaphore; if sval is positive, no process is waiting. RETURN VALUES
Upon successful completion, sem_getvalue() returns 0. Otherwise, it returns -1 and sets errno to indicate the error. ERRORS
The sem_getvalue() function will fail if: EINVAL The sem argument does not refer to a valid semaphore. ENOSYS The sem_getvalue() function is not supported by the system. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
semctl(2), semget(2), semop(2), sem_post(3RT), sem_wait(3RT), attributes(5), standards(5) SunOS 5.10 1 Nov 2003 sem_getvalue(3RT)
Man Page

3 More Discussions You Might Find Interesting

1. Programming

Semaphore Segmentation Fault

When I execute the first 4 lines of code , it works fine. But the output gives a segmentation fault on executing the sem_getvalue() function. I looke up everywhere for the syntax and other mistakes but I am not being able to find out whats wrong with the code. Can anyone please help me on that...??... (8 Replies)
Discussion started by: tejbuch
8 Replies

2. UNIX for Dummies Questions & Answers

Determining which processes hold a semaphore

I have a situation where I have created a semaphore and set it's value to 10. I am using this semaphore to control access to a shared memory location. I can have 10 processes simultaneously read from the shared memory location, process 11 would get locked out. My question is, is there a way I... (6 Replies)
Discussion started by: tpotter01
6 Replies

3. Shell Programming and Scripting

Conditional deletion of files based on extension

Hello All, I have some files like file, file.chk, file.sem and file.temp in huge. I would like to delete some files based on following criteria. 1. Unconditionally delete .sem and .temp files 2. If we found the actual file, don't remove .chk file, otherwise remove .chk file as well for... (5 Replies)
Discussion started by: VasuKukkapalli
5 Replies