#include <sys/sem.h>
/*#include <sys/types.h>*/
/*Initialize spin lock:*/
void spin_lock_init(lok)
int *lok;
{
  int init_sem_value = 1;             /* unlocked */
  *lok = semget(IPC_PRIVATE, 1, (0600 | IPC_CREAT) );
  if (*lok == -1){                    /* if call unsuccessful */
    perror("semget");
    exit(1);
  }
  if (semctl(*lok, 0, SETVAL, init_sem_value) < 0) {
    perror("semctl");
    exit(1);
  }                                   /* end of spin_lock_init */
}

