Where the SEM_NSEMS_MAX is defined?

Ángel González keisial@gmail.com
Fri Feb 3 17:57:00 GMT 2012


Ryan S. Arnold wrote:
> Perhaps _POSIX_SEM_NSEMS_MAX is an artifact of some historical
> semaphore pool concept?
>
> Ryan
Posix specifies errors for which a conforming implementation may fail the
(in this instance) semaphore creation. But an implementation can as well
not impose such limits.

We can easily test the Linux limits:
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
int main() {
    errno = 0;
    long limit = sysconf(_SC_SEM_NSEMS_MAX);
    printf("Limit: %ld\nerrno: %d\n\n", limit, errno);
    return 0;
}

Which return
> Limit: -1
> errno: 0
And from sysconf(3):
> In the case of limits, -1 means that there is no definite limit.




More information about the Libc-help mailing list