Correzioni alle funzioni di locking
authorSimone Piccardi <piccardi@gnulinux.it>
Mon, 6 Jan 2003 22:46:42 +0000 (22:46 +0000)
committerSimone Piccardi <piccardi@gnulinux.it>
Mon, 6 Jan 2003 22:46:42 +0000 (22:46 +0000)
ipc.tex

diff --git a/ipc.tex b/ipc.tex
index bf63e66f9e4355888f84f31e246b793f46cf5ea7..6cb8cc482a4bdbd2811d480609a84c2f882b8854 100644 (file)
--- a/ipc.tex
+++ b/ipc.tex
@@ -3387,23 +3387,17 @@ leggermente pi
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
     \begin{lstlisting}{} 
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
     \begin{lstlisting}{} 
-/*
- * Function CreateMutex: Create a mutex using file locking.  
- */
+/* Function CreateMutex: Create a mutex using file locking. */
 int CreateMutex(const char *path_name)
 {
     return open(path_name, O_EXCL|O_CREAT);
 }
 int CreateMutex(const char *path_name)
 {
     return open(path_name, O_EXCL|O_CREAT);
 }
-/*
- * Function UnlockMutex: unlock a file.  
- */
+/* Function UnlockMutex: unlock a file. */
 int FindMutex(const char *path_name)
 {
     return open(path_name, O_RDWR);
 }
 int FindMutex(const char *path_name)
 {
     return open(path_name, O_RDWR);
 }
-/*
- * Function LockMutex: lock mutex using file locking.
- */
+/* Function LockMutex: lock mutex using file locking. */
 int LockMutex(int fd)
 {
     struct flock lock;                                /* file lock structure */
 int LockMutex(int fd)
 {
     struct flock lock;                                /* file lock structure */
@@ -3416,9 +3410,7 @@ int LockMutex(int fd)
     /* do locking */
     return fcntl(fd, F_SETLKW, &lock);
 }
     /* do locking */
     return fcntl(fd, F_SETLKW, &lock);
 }
-/*
- * Function UnlockMutex: unlock a file.  
- */
+/* Function UnlockMutex: unlock a file. */
 int UnlockMutex(int fd)
 {
     struct flock lock;                                /* file lock structure */
 int UnlockMutex(int fd)
 {
     struct flock lock;                                /* file lock structure */
@@ -3430,16 +3422,12 @@ int UnlockMutex(int fd)
     /* do locking */
     return fcntl(fd, F_SETLK, &lock);
 }
     /* do locking */
     return fcntl(fd, F_SETLK, &lock);
 }
-/*
- * Function RemoveMutex: remove a mutex (unlinking the lock file).
- */
+/* Function RemoveMutex: remove a mutex (unlinking the lock file). */
 int RemoveMutex(const char *path_name)
 {
     return unlink(path_name);
 }
 int RemoveMutex(const char *path_name)
 {
     return unlink(path_name);
 }
-/*
- * Function ReadMutex: read a mutex status.
- */
+/* Function ReadMutex: read a mutex status. */
 int ReadMutex(int fd)
 {
     int res;
 int ReadMutex(int fd)
 {
     int res;
@@ -3463,11 +3451,14 @@ int ReadMutex(int fd)
   \label{fig:ipc_flock_mutex}
 \end{figure}
 
   \label{fig:ipc_flock_mutex}
 \end{figure}
 
-Il codice per implementare un mutex utilizzando il file
-locking\index{file!locking} è riportato in \figref{fig:ipc_flock_mutex}; a
-differenza del precedente caso in cui si sono usati i semafori le funzioni
-questa volta sono sufficienti due funzioni, \func{LockMutex} e
-\func{UnlockMutex}, usate rispettivamente per acquisire e rilasciare il mutex.
+Il codice delle varie funzioni definite per implementare un mutex utilizzando
+il file locking\index{file!locking} è riportato in
+\figref{fig:ipc_flock_mutex}; si è mantenuta una struttura analoga a quelle
+viste in precedenza, anche se le due interfacce non possono essere
+completamente equivalenti, specie per quanto riguarda la rimozione del mutex.
+
+
+
 
 La prima funzione (\texttt{\small 1--22}) serve per acquisire il mutex.
 Anzitutto si apre (\texttt{\small 9--11}), creandolo se non esiste, il file
 
 La prima funzione (\texttt{\small 1--22}) serve per acquisire il mutex.
 Anzitutto si apre (\texttt{\small 9--11}), creandolo se non esiste, il file