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

semget( ) failes



Hello,

I am a newbae for linux and as well as to axis need some help.......
I have a problem in using the system call semget(). It always fails with
an error function is not implemented.
I have support for IPC in my kernel configuration.

The code that I  ma using works well for my linux machine....

I dont really what exactly is the problem..

The piece of code that i am trying is,



 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/sem.h>
                                                                                                               
 union semun {
               int val;
               struct semid_ds *buf;
               ushort *array;
          };
                                                                                                               
main()
{
  FILE * fp;
  int i,j;
  int pid;
  int semid; /* semid of semaphore set */
  key_t key = 12; /* key to pass to semget() */
  int semflg = IPC_CREAT | 0666; /* semflg to pass to semget() */
  int nsems = 1; /* nsems to pass to semget() */
  int nsops; /* number of operations to do */
  struct sembuf *sops = (struct sembuf *) malloc(2*sizeof(struct
sembuf));
  /* ptr to operations to perform */
                                                                                                               
  /* set up semaphore */
                                                                                                               
  fp=fopen("ErrorLog","w");
                                                                                                               
  (void) fprintf(stderr, "\nsemget: Setting up seamaphore: semget(%#lx,
%\
%#o)\n",key, nsems, semflg);
   if ((semid = semget(key, nsems, semflg)) == -1) {
        printf("semget: semget failed");
        exit(1);
      } else
        (void) fprintf(stderr, "semget: semget succeeded: semid =\
%d\n", semid);


}

This piece of code works fine with my machine but not for the developer
board,

Waiting for ur responses again,




Regards,
Ajay.