[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

sem_open / how to use NPTL?



Hello everybody,

forgive me for bothering you, but after hours and hours of searching, I'm
stuck. For my university, I've to program some easy things with POSIX.4
semaphores. I know that I need kernel 2.6 and NPTL for that, and I have
kernel 2.6.7, gcc 3.3.5 and libc6-i686 well installed. But a minimal
program, shown below, compiled with "gcc -o minimal -lpthread minimal.c"
keeps saying "sem_open: function not implemented" as if I were still using
old LinuxThreads. However, getconf says:

$ getconf _POSIX_SEMAPHORES
1
$ getconf GNU_LIBPTHREAD_VERSION
NPTL 0.60

On Fedora Cora 2 (computer at my university that I connected via ssh), it
works flawlessly. What am I missing?

Thanks for reading,
have a nice day,
Viktor.


### minimal.c

#define _POSIX_SOURCE 1
#define  _XOPEN_SOURCE 1
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <semaphore.h>

int main (int argc, char **argv) {
 sem_t* mysem;
 if ((mysem = sem_open("/mysem", O_CREAT, S_IRWXU, 1)) == SEM_FAILED) {
   perror("sem_open");
   return EXIT_FAILURE;
 }
}




Reply to: