/* * Get the current value of the mutex * New File Mar 23,1989 * Author Jerry LeVan * */ #include #include #include #include #define COUNT 1 /* How many we are going to create */ #define PERM 0666 /* all can read write */ #define KEY 'JHL ' /* our key */ main() { int id; int result; id = semget(KEY,0,0); printf("status of get key = %d\n",id); if(id == -1) {perror("Bad Semaphore ID fetch"); exit();} /* now get the value */ result = semctl(id,0,GETVAL,0); if(result == -1){ perror("Bad Get Value Call");exit();} printf("the value is -> %d\n",result); }