From: Simone Piccardi Date: Sun, 9 Sep 2001 22:45:34 +0000 (+0000) Subject: Completate le aggiunte della GPL per i programmi X-Git-Url: https://gapil.gnulinux.it/gitweb/?a=commitdiff_plain;h=54d27b07aee6d293931ee274a3ede927f517f2cf;p=gapil.git Completate le aggiunte della GPL per i programmi --- diff --git a/prochand.tex b/prochand.tex index 8f8beaf..41d7a34 100644 --- a/prochand.tex +++ b/prochand.tex @@ -278,20 +278,54 @@ numero di figli specificato a linea di comando; il codice completo, compresa la parte che gestisce le opzioni a riga di comando, è disponibile nel file \file{ForkTest.c}. -Decifrato il numero di figli da creare il ciclo principale del programma +Decifrato il numero di figli da creare, il ciclo principale del programma (\texttt{\small 28--40}) esegue in successione la creazione dei processi figli -(\texttt{\small 29--31}) controllando il successo della chiamata a -\func{fork}; ciascun figlio (\texttt{\small 29--31}) si limita a stampare il +controllando il successo della chiamata a \func{fork} (\texttt{\small + 29--31}); ciascun figlio (\texttt{\small 29--31}) si limita a stampare il suo numero di successione, attendere 2 secondi e scrivere un messaggio prima di uscire. Il processo padre invece (\texttt{\small 29--31}) stampa un -messaggio di creazione e procede nell'esecuzione del ciclo. - -In generale\footnote{anche se nel kernel 2.4.x è stato introdotto un +messaggio di creazione e procede nell'esecuzione del ciclo. Se eseguiamo il +comando otterremo: +\begin{verbatim} +[piccardi@selidor sources]$ ./forktest 5 +Test for forking 5 child +Spawned 1 child, pid 840 +Child 1 successfully executing +Child 2 successfully executing +Spawned 2 child, pid 841 +Spawned 3 child, pid 842 +Child 3 successfully executing +Spawned 4 child, pid 843 +Child 4 successfully executing +Child 5 successfully executing +Spawned 5 child, pid 844 +[piccardi@selidor sources]$ Child 2 exiting +Child 1 exiting +Child 4 exiting +Child 3 exiting +Child 5 exiting +\end{verbatim} + + +Come si vede non si può dire quale processo fra il padre ed il figlio venga +eseguito per primo\footnote{anche se nel kernel 2.4.x era stato introdotto un meccanismo che metteva in esecuzione sempre il xxx per primo (TODO - recuperare le informazioni esatte)} non si può dire quale processo fra il -padre ed il figlio venga eseguito per primo dopo la chiamata a \func{fork}, -per cui se i due processi devono essere sincronizzati occorre ricorrere ad un -qualche meccanismo di intercomunicazione. + recuperare le informazioni esatte)} dopo la chiamata a \func{fork}, nel caso +mostrato sopra ad esempio si può notare come dopo la creazione il secondo ed +il quinto figlio sia stato stati eseguiti per primi, mantre per gli altri +figli è stato eseguito per primo il padre. In generale l'ordine di esecuzione +dipenderà dalla situazione particolare in si trova la macchina al momento +della chiamata, risultando del tutto impredicibile, per questo motivo se i due +processi devono essere sincronizzati occorrerà ricorrere ad un opportuno +meccanismo di intercomunicazione. + +Si ricordi inoltre che, essendo i segmenti di memoria utilizzati dai singoli +processi completamente separati, le modifiche delle variabili nei processi +figli (come l'incremento di \var{i} in \texttt{\small 33}) saranno effettive +solo per essi, e non hanno alcun effetto sul valore che le stesse variabili +hanno nel processo padre. + + \subsection{Le funzioni \texttt{wait} e \texttt{waitpid}} diff --git a/sources/ElemDaytimeTCPClient.c b/sources/ElemDaytimeTCPClient.c index d241f16..d049b7d 100644 --- a/sources/ElemDaytimeTCPClient.c +++ b/sources/ElemDaytimeTCPClient.c @@ -19,14 +19,14 @@ /**************************************************************** * * Program daytime: - * Simple TCP client for daytime service (port 13) + * Elementary TCP client for daytime service (port 13) * * Author: Simone Piccardi * Apr. 2001 * * Usage: daytime -h give all info's * - * $Id: ElemDaytimeTCPClient.c,v 1.1 2001/09/09 17:39:15 piccardi Exp $ + * $Id: ElemDaytimeTCPClient.c,v 1.2 2001/09/09 22:45:34 piccardi Exp $ * ****************************************************************/ /* diff --git a/sources/ElemDaytimeTCPServer.c b/sources/ElemDaytimeTCPServer.c index 057ce97..9ab656a 100644 --- a/sources/ElemDaytimeTCPServer.c +++ b/sources/ElemDaytimeTCPServer.c @@ -1,6 +1,6 @@ -/* ElemDaytimeTCPClient.c +/* ElemDaytimeTCPServer.c * - * Copyright (C) 2000 Simone Piccardi + * Copyright (C) 2001 Simone Piccardi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -//**************************************************************** +/**************************************************************** * * Program daytimed: * Elementary TCP server for daytime service (port 13) @@ -24,9 +24,9 @@ * Author: Simone Piccardi * Apr. 2001 * - * Usage: daytimed + * Usage: daytimed -h give all info * - * $Id: ElemDaytimeTCPServer.c,v 1.2 2001/09/09 17:39:15 piccardi Exp $ + * $Id: ElemDaytimeTCPServer.c,v 1.3 2001/09/09 22:45:34 piccardi Exp $ * ****************************************************************/ /* diff --git a/sources/ElemEchoTCPClient.c b/sources/ElemEchoTCPClient.c index eafdc81..57b8fa1 100644 --- a/sources/ElemEchoTCPClient.c +++ b/sources/ElemEchoTCPClient.c @@ -1,6 +1,24 @@ +/* ElemEchoTCPClient.c + * + * Copyright (C) 2001 Simone Piccardi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /**************************************************************** * - * Program SimpleEchoTCPClient: + * Program ElemEchoTCPClient.c * Simple TCP client for echo service (port 7) * * Author: Simone Piccardi @@ -8,7 +26,7 @@ * * Usage: echo -h give all info's * - * $Id: ElemEchoTCPClient.c,v 1.2 2001/06/20 22:03:37 piccardi Exp $ + * $Id: ElemEchoTCPClient.c,v 1.3 2001/09/09 22:45:34 piccardi Exp $ * ****************************************************************/ /* diff --git a/sources/ErrCode.c b/sources/ErrCode.c index 58f5491..5106885 100644 --- a/sources/ErrCode.c +++ b/sources/ErrCode.c @@ -1,3 +1,21 @@ +/* ErrCode.c + * + * Copyright (C) 2001 Simone Piccardi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /**************************************************************** * * Program ErrCode.c: @@ -8,7 +26,7 @@ * * Usage: errcode -h give all info's * - * $Id: ErrCode.c,v 1.1 2001/09/09 17:39:15 piccardi Exp $ + * $Id: ErrCode.c,v 1.2 2001/09/09 22:45:34 piccardi Exp $ * ****************************************************************/ /* diff --git a/sources/ForkTest.c b/sources/ForkTest.c index da38629..09035d5 100644 --- a/sources/ForkTest.c +++ b/sources/ForkTest.c @@ -1,3 +1,21 @@ +/* ForkTest.c + * + * Copyright (C) 2001 Simone Piccardi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /**************************************************************** * * Program ForkTest.c: @@ -8,7 +26,7 @@ * * Usage: forktest -h give all info's * - * $Id: ForkTest.c,v 1.1 2001/09/09 17:39:15 piccardi Exp $ + * $Id: ForkTest.c,v 1.2 2001/09/09 22:45:34 piccardi Exp $ * ****************************************************************/ /* @@ -69,15 +87,15 @@ int main(int argc, char *argv[]) /* loop to fork children */ for (i=0; i #include diff --git a/sources/SockWrite.c b/sources/SockWrite.c index 466807c..c0a41d9 100644 --- a/sources/SockWrite.c +++ b/sources/SockWrite.c @@ -1,3 +1,32 @@ +/* SockWrite.c + * + * Copyright (C) 2001 Simone Piccardi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/**************************************************************** + * + * Routine SockWrite + * Routine to write an exact number of bytes into a socket + * + * Author: Simone Piccardi + * Jun. 2001 + * + * $Id: SockWrite.c,v 1.3 2001/09/09 22:45:34 piccardi Exp $ + * + ****************************************************************/ #include #include