X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=thread.tex;h=62f4dfdf7e9bc388c02835965d9a36b120d6c0d5;hp=a6c6dd7a53a3de41311d7f32a3d03941aa489ac0;hb=0e932d7963332ca87688c3695d7386d45ddcc46a;hpb=7e19b798d0cc09960daad695d8f3b242170bb3b4 diff --git a/thread.tex b/thread.tex index a6c6dd7..62f4dfd 100644 --- a/thread.tex +++ b/thread.tex @@ -1,6 +1,6 @@ %% thread.tex %% -%% Copyright (C) 2007-2018 Simone Piccardi. Permission is granted to +%% Copyright (C) 2007-2019 Simone Piccardi. Permission is granted to %% copy, distribute and/or modify this document under the terms of the GNU Free %% Documentation License, Version 1.1 or any later version published by the %% Free Software Foundation; with the Invariant Sections being "Un preambolo", @@ -105,7 +105,7 @@ Tratteremo in questa sezione l'interfaccia di programmazione con i stata seguita anche dalle varie implementazioni dei \textit{thread} realizzate su Linux, ed in particolare dalla \textit{Native Thread Posix Library} che è stata integrata con i kernel della serie 2.6 e che fa parte a pieno titolo -delle \acr{glibc}. +della \acr{glibc}. \subsection{Una panoramica} @@ -116,6 +116,28 @@ delle \acr{glibc}. \label{sec:pthread_management} +Benché la funzione sia utilizzabile anche con i processi, tanto che a partire +dalla versione 2.3 della \acr{glibc} viene a sostituire \func{\_exit} (tramite +un \textit{wrapper} che la utilizza al suo posto) per la terminazione di tutti +i \textit{thread} di un processo si deve usare la funzione di sistema +\func{exit\_group}, il cui prototipo è: + +\begin{funcproto}{ +\fhead{linux/unistd.h} +\fdecl{void exit\_group(int status)} +\fdesc{Termina tutti i \textit{thread} di un processo.} +} +{La funzione non ha errori e pertanto non ritorna.} +\end{funcproto} + +La funzione è sostanzialmente identica alla \textit{system call} \func{\_exit} +ma a differenza di quest'ultima, che termina solo il \textit{thread} +chiamante, termina tutti \textit{thread} del processo. + + +\section{La sincronizzazione dei \textit{thread}} +\label{sec:pthread_sync} + \subsection{I \textit{mutex}} \label{sec:pthread_mutex}