5
/* $Id: semaphores.c,v 1.12 2005-03-10 19:11:23 vinodtipparaju Exp $ */
6
#include "semaphores.h"
19
int semget(),semctl();
30
semaphoreID = semget(IPC_PRIVATE,num_sem, IPC_CREAT | 0600);
32
fprintf(stderr," Semaphore Allocation Failed \nsuggestions to fix the problem: \n");
33
fprintf(stderr," 1. run ipcs and ipcrm -s commands to clean any semaphore ids\n");
34
fprintf(stderr," 2. verify if constant SEMMSL defined in file semaphore.h is set correctly for your system\n");
35
fprintf(stderr," 3. recompile semaphore.c\n");
37
perror("Error message from failed semget:");
38
armci_die(" exiting ...", num_sem);
41
num_sem_alloc = num_sem;
45
void SemInit(id,value)
48
int i, semid, num_sem;
49
union semun semctl_arg;
51
semctl_arg.val = value;
53
if(id == ALL_SEMS){ semid = 0; num_sem = num_sem_alloc;}
54
else { semid = id; num_sem = 1;}
56
for(i=0; i< num_sem; i++){
57
if( semctl(semaphoreID, semid, SETVAL,semctl_arg )<0){
59
armci_die("SemInit error",id);
66
/* release semaphore(s) */
71
/* this is only to avoid compiler whinning about the unitialized variable*/
74
(void) semctl(semaphoreID,0,IPC_RMID,dummy);
78
void Sem_CreateInitLocks(int num, lockset_t *id)
85
void Sem_InitLocks(int num, lockset_t id)
92
void Sem_DeleteLocks(lockset_t id)
96
/* this is only to avoid compiler whinning about the unitialized variable*/
99
(void) semctl(id,0,IPC_RMID,dummy);