Since you don't seem to follow instructions, I don't expect you to benchmark the following code. In case you do, however, and your results are still widely unexpected, please make a note of it here.
Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <time.h>
#define NSEMS 2
main(int argc, char *argv[])
{
time_t start,stop;
long int i;
int sid;
key_t key;
ushort vals[NSEMS] = { 0, 0 };
key = ftok("/tmp",99);
start=time(NULL);
for (i = 0; i < 5000000; i++) {
if ((sid = semget(key, NSEMS, IPC_CREAT | 0777)) == -1) {
perror("Can Not Get Semaphore ID");
}
if (semctl(sid, NSEMS, GETALL, vals) == -1) {
perror("Can Not Get Semaphore Values");
}
}
stop=time(NULL);
printf("%.2f semop/s [%i,%i]\n", (double)i/(stop-start), vals[0], vals[1]);
}