Nouvi esempi finiti. E scritto un po' di roba
[gapil.git] / sources / Mutex.c
index d0099982305d5d42c0b1c36ac3baead2afac66f1..076c59360c430c4efe973064b8ce7e45765cddfe 100644 (file)
@@ -22,7 +22,7 @@
  *
  * Author: S. Piccardi Dec. 2002
  *
- * $Id: Mutex.c,v 1.3 2002/12/05 23:38:22 piccardi Exp $
+ * $Id: Mutex.c,v 1.4 2003/01/04 17:24:30 piccardi Exp $
  *
  *****************************************************************************/
 #include <sys/sem.h>     /* IPC semaphore declarations */
@@ -65,7 +65,7 @@ int MutexCreate(key_t ipc_key)
  */
 int MutexFind(key_t ipc_key) 
 {
-    return semget(ipc_key,1,0);
+    return semget(ipc_key, 1, 0);
 }
 /*
  * Function MutexRead: read the current value of the mutex/semaphore
@@ -109,6 +109,16 @@ int MutexUnlock(int sem_id)
 {
     return semop(sem_id, &sem_ulock, 1);
 }
+/*
+ * Function MutexRemove: remove a mutex/semaphore
+ *
+ * Input:  a semaphore id #
+ * Return: return code of semctl
+ */
+int MutexRemove(int sem_id) 
+{
+    return semctl(sem_id, 0, IPC_RMID);
+}
 /***************************************************************************** 
  *
  * File locking mutex