Aggiunte i listati per poter usare le modifiche di Mirko, con la generazione
[gapil.git] / ipc.tex
diff --git a/ipc.tex b/ipc.tex
index 25274c996d97179f9ed1a53057c3c64bc8100b1f..e4c32b7bca1b8eaa53e26ab804fde1b6b1aeda6b 100644 (file)
--- a/ipc.tex
+++ b/ipc.tex
@@ -1002,7 +1002,7 @@ mantiene varie propriet
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
-    \begin{lstlisting}[labelstep=0]{}%,frame=,indent=1cm ]{}
+    \begin{lstlisting}[stepnumber=0]{}%,frame=,indent=1cm ]{}
 struct ipc_perm
 {
     key_t key;                        /* Key.  */
 struct ipc_perm
 {
     key_t key;                        /* Key.  */
@@ -1415,7 +1415,7 @@ kernel.\footnote{lo schema illustrato in \figref{fig:ipc_mq_schema} 
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
-    \begin{lstlisting}[labelstep=0]{}
+    \begin{lstlisting}[stepnumber=0]{}
 struct msqid_ds {
     struct ipc_perm msg_perm;     /* structure for operation permission */
     time_t msg_stime;             /* time of last msgsnd command */
 struct msqid_ds {
     struct ipc_perm msg_perm;     /* structure for operation permission */
     time_t msg_stime;             /* time of last msgsnd command */
@@ -1595,7 +1595,7 @@ dovr
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
-    \begin{lstlisting}[labelstep=0]{}
+    \begin{lstlisting}[stepnumber=0]{}
     struct msgbuf {
          long mtype;          /* message type, must be > 0 */
          char mtext[LENGTH];  /* message data */
     struct msgbuf {
          long mtype;          /* message type, must be > 0 */
          char mtext[LENGTH];  /* message data */
@@ -2087,7 +2087,7 @@ semaforo all'uscita del processo.
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
-    \begin{lstlisting}[labelstep=0]{}
+    \begin{lstlisting}[stepnumber=0]{}
 struct semid_ds
 {
     struct ipc_perm sem_perm;           /* operation permission struct */
 struct semid_ds
 {
     struct ipc_perm sem_perm;           /* operation permission struct */
@@ -2137,7 +2137,7 @@ controllo.
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
-    \begin{lstlisting}[labelstep=0]{}
+    \begin{lstlisting}[stepnumber=0]{}
 struct sem {
   short   sempid;         /* pid of last operation */
   ushort  semval;         /* current value */
 struct sem {
   short   sempid;         /* pid of last operation */
   ushort  semval;         /* current value */
@@ -2234,7 +2234,7 @@ specificata con \param{cmd}, ed opera o sull'intero insieme specificato da
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
-    \begin{lstlisting}[labelstep=0]{}
+    \begin{lstlisting}[stepnumber=0]{}
 union semun {
       int val;                  /* value for SETVAL */
       struct semid_ds *buf;     /* buffer for IPC_STAT, IPC_SET */
 union semun {
       int val;                  /* value for SETVAL */
       struct semid_ds *buf;     /* buffer for IPC_STAT, IPC_SET */
@@ -2388,7 +2388,7 @@ effettivamente eseguite se e soltanto se 
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
-    \begin{lstlisting}[labelstep=0]{}
+    \begin{lstlisting}[stepnumber=0]{}
 struct sembuf
 {
   unsigned short int sem_num;   /* semaphore number */
 struct sembuf
 {
   unsigned short int sem_num;   /* semaphore number */
@@ -2749,7 +2749,7 @@ norma, significa insieme a dei semafori.
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
-    \begin{lstlisting}[labelstep=0]{}
+    \begin{lstlisting}[stepnumber=0]{}
 struct shmid_ds {
      struct    ipc_perm shm_perm;  /* operation perms */
      int  shm_segsz;               /* size of segment (bytes) */
 struct shmid_ds {
      struct    ipc_perm shm_perm;  /* operation perms */
      int  shm_segsz;               /* size of segment (bytes) */
@@ -3924,7 +3924,7 @@ per
 Benedyczak,\footnote{i patch al kernel e la relativa libreria possono essere
 trovati su
 \href{http://www.mat.uni.torun.pl/~wrona/posix_ipc}
 Benedyczak,\footnote{i patch al kernel e la relativa libreria possono essere
 trovati su
 \href{http://www.mat.uni.torun.pl/~wrona/posix_ipc}
-{http://www.mat.uni.torun.pl/\~{}wrona/posix\_ipc}.}.
+{http://www.mat.uni.torun.pl/\tild{}wrona/posix\_ipc}.}.
 In generale, come le corrispettive del SysV IPC, le code di messaggi sono poco
 usate, dato che i socket\index{socket}, nei casi in cui sono sufficienti, sono
 più comodi, e che in casi più complessi la comunicazione può essere gestita
 In generale, come le corrispettive del SysV IPC, le code di messaggi sono poco
 usate, dato che i socket\index{socket}, nei casi in cui sono sufficienti, sono
 più comodi, e che in casi più complessi la comunicazione può essere gestita
@@ -4037,7 +4037,7 @@ struttura \struct{mq\_attr}, la cui definizione 
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
 \begin{figure}[!htb]
   \footnotesize \centering
   \begin{minipage}[c]{15cm}
-    \begin{lstlisting}[labelstep=0]{}
+    \begin{lstlisting}[stepnumber=0]{}
 struct mq_attr {
         long    mq_flags;       /* message queue flags                  */
         long    mq_maxmsg;      /* maximum number of messages           */
 struct mq_attr {
         long    mq_flags;       /* message queue flags                  */
         long    mq_maxmsg;      /* maximum number of messages           */
@@ -4509,8 +4509,8 @@ mappati in memoria; questi verranno cancellati automaticamente dal sistema
 solo con le rispettive chiamate a \func{close} e \func{munmap}.  Una volta
 eseguita questa funzione però, qualora si richieda l'apertura di un segmento
 con lo stesso nome, la chiamata a \func{shm\_open} fallirà, a meno di non aver
 solo con le rispettive chiamate a \func{close} e \func{munmap}.  Una volta
 eseguita questa funzione però, qualora si richieda l'apertura di un segmento
 con lo stesso nome, la chiamata a \func{shm\_open} fallirà, a meno di non aver
-usato \const{O\_CREAT}, nel qual caso comunque si otterrà il riferimento ad un
-segmento distinto dal precedente.
+usato \const{O\_CREAT}, in quest'ultimo caso comunque si otterrà un file
+descriptor che fa riferimento ad un segmento distinto da eventuali precedenti.
 
 \begin{figure}[!htb]
   \footnotesize \centering
 
 \begin{figure}[!htb]
   \footnotesize \centering
@@ -4559,8 +4559,7 @@ void * FindShm(char * shm_name, off_t shm_size)
 /* Function RemoveShm: Remove a POSIX shared memory segment */
 int RemoveShm(char * shm_name)
 {
 /* Function RemoveShm: Remove a POSIX shared memory segment */
 int RemoveShm(char * shm_name)
 {
-    shm_unlink(shm_name);
-    return 0;
+    return shm_unlink(shm_name);
 }
     \end{lstlisting}
   \end{minipage} 
 }
     \end{lstlisting}
   \end{minipage} 
@@ -4570,16 +4569,17 @@ int RemoveShm(char * shm_name)
   \label{fig:ipc_posix_shmmem}
 \end{figure}
 
   \label{fig:ipc_posix_shmmem}
 \end{figure}
 
-Come esempio di queste funzioni vediamo come è possibile riscrivere con esse
-funzioni analoghe a quelle viste in \secref{fig:ipc_sysv_shm_func}; il codice,
-riportato in \figref{fig:ipc_posix_shmmem}, è sempre contenuto nel file
-\file{SharedMem.c} dei sorgenti allegati.
+Come esempio per l'uso di queste funzioni vediamo come è possibile riscrivere
+una interfaccia semplificata analoga a quella vista in
+\secref{fig:ipc_sysv_shm_func} per la memoria condivisa in stile SysV. Il
+codice, riportato in \figref{fig:ipc_posix_shmmem}, è sempre contenuto nel
+file \file{SharedMem.c} dei sorgenti allegati.
 
 La prima funzione (\texttt{\small 1--24}) è \func{CreateShm} che, dato un nome
 nell'argomento \var{name} crea un nuovo segmento di memoria condivisa,
 accessibile in lettura e scrittura, e ne restituisce l'indirizzo. Anzitutto si
 definiscono (\texttt{\small 8}) i flag per la successiva (\texttt{\small 9})
 
 La prima funzione (\texttt{\small 1--24}) è \func{CreateShm} che, dato un nome
 nell'argomento \var{name} crea un nuovo segmento di memoria condivisa,
 accessibile in lettura e scrittura, e ne restituisce l'indirizzo. Anzitutto si
 definiscono (\texttt{\small 8}) i flag per la successiva (\texttt{\small 9})
-chiamata a \func{shm\_open} che apre il segmento in lettura e scrittura
+chiamata a \func{shm\_open}, che apre il segmento in lettura e scrittura
 (creandolo se non esiste, ed uscendo in caso contrario) assegnandogli sul
 filesystem i permessi specificati dall'argomento \var{perm}. In caso di errore
 (\texttt{\small 10--12}) si restituisce un puntatore nullo, altrimenti si
 (creandolo se non esiste, ed uscendo in caso contrario) assegnandogli sul
 filesystem i permessi specificati dall'argomento \var{perm}. In caso di errore
 (\texttt{\small 10--12}) si restituisce un puntatore nullo, altrimenti si
@@ -4603,11 +4603,12 @@ memoria con \func{mmap}, restituendo (\texttt{\small 36--38}) un puntatore
 nullo in caso di errore, o l'indirizzo (\texttt{\small 39}) dello stesso in
 caso di successo.
 
 nullo in caso di errore, o l'indirizzo (\texttt{\small 39}) dello stesso in
 caso di successo.
 
-La terza funzione (\texttt{\small 40--46}) è \func{FindShm}, e serve a
+La terza funzione (\texttt{\small 40--45}) è \func{RemoveShm}, e serve a
 cancellare un segmento di memoria condivisa. Dato che al contrario di quanto
 avveniva con i segmenti del SysV IPC gli oggetti allocati nel kernel vengono
 rilasciati automaticamente quando nessuna li usa più, tutto quello che c'è da
 cancellare un segmento di memoria condivisa. Dato che al contrario di quanto
 avveniva con i segmenti del SysV IPC gli oggetti allocati nel kernel vengono
 rilasciati automaticamente quando nessuna li usa più, tutto quello che c'è da
-fare (\texttt{\small 45}) in questo caso è chiamare \func{shm\_unlink}.
+fare (\texttt{\small 44}) in questo caso è chiamare \func{shm\_unlink},
+retituendo al chiamante il valore di ritorno.