From: Simone Piccardi Date: Wed, 10 Jan 2024 11:18:24 +0000 (+0100) Subject: Aggiornamento note copyright X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=commitdiff_plain;h=HEAD;hp=f21f63518fb77f32a2474564e1a3c2f4c32cccd4 Aggiornamento note copyright --- diff --git a/build.tex b/build.tex index cec0b2d..ad1ba8f 100644 --- a/build.tex +++ b/build.tex @@ -1,6 +1,6 @@ %% build.tex %% -%% Copyright (C) 1999-2019 Simone Piccardi. Permission is granted to copy, +%% Copyright (C) 1999-2024 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", diff --git a/domandemanpages.txt b/domandemanpages.txt index a06a041..1d2bba8 100644 --- a/domandemanpages.txt +++ b/domandemanpages.txt @@ -6,3 +6,9 @@ Con readv/writev che fine ha fatto EOPNOTSUPP? tee ed il supporto per i socket ? openat e il supposto problema della race condition. + + +Con sigwait si dice che viene restituito un valore positivo in caso di errore +ma si elenca soltanto EINVAL, ma se si usa un puntatore non valido, che +succede? Prima era elencato anche EFAULT, ora no. Dal codice sembrerebbe + diff --git a/errors.tex b/errors.tex index b8b6a8f..18d618c 100644 --- a/errors.tex +++ b/errors.tex @@ -1,6 +1,6 @@ %% errors.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/fileadv.tex b/fileadv.tex index 948f721..1bce388 100644 --- a/fileadv.tex +++ b/fileadv.tex @@ -1,6 +1,6 @@ %% fileadv.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", @@ -925,6 +925,7 @@ attuale delle cose è sconsigliabile fare affidamento sul \textit{mandatory % TODO il supporto è stato reso opzionale nel 4.5, verrà eliminato nel futuro % (vedi http://lwn.net/Articles/667210/) +% è stato eliminato nel 5.15 \itindend{file~locking} @@ -3498,6 +3499,10 @@ raggruppati in un solo evento. % http://lwn.net/Articles/343346/ (incluso nel 2.6.36) % fanotify_mark() ha FAN_MARK_FILESYSTEM dal 4.20 % fanotify() ha FAN_OPEN_EXEC dal 4.21/5.0 +% fanotify() ha FAN_REPORT_PIDFD dal 5.14 +% fanotify() ha FAN_FS_ERROR dal 5.16, vedi +% https://docs.kernel.org/admin-guide/filesystem-monitoring.html +% fanotify() ha FAN_RENAME dal 5.17, vedi https://kernelnewbies.org/Linux_5.17 \subsection{L'interfaccia POSIX per l'I/O asincrono} @@ -4733,7 +4738,9 @@ caching dei dati. % https://lwn.net/Articles/733256/). % TODO aggiunte MADV_COLD e MADV_PAGEOUT dal kernel 5.4, vedi % https://git.kernel.org/linus/9c276cc65a58 e -% https://git.kernel.org/linus/1a4e58cce84e +% https://git.kernel.org/linus/1a4e58cce84e +% TODO: aggiunte MADV_POPULATE_READ e MADV_POPULATE_WRITE (vedi +% https://lwn.net/Articles/861695/) \footnotetext{a partire dal kernel 2.6.32 è stato introdotto un meccanismo che identifica pagine di memoria identiche e le accorpa in una unica pagina @@ -5862,6 +5869,12 @@ da fare % TODO: trattare i file seal, vedi fcntl / F_ADD_SEAL e memfd_create +% TODO: con il kernel 5.14 è stata introdotta la syscall memfd_secret, vedi +% https://lwn.net/Articles/835342/ https://lwn.net/Articles/812325/ +% https://lwn.net/Articles/865256/ +% https://lwn.net/ml/linux-mm/20210729082900.1581359-1-rppt@kernel.org/ e +% https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1507f51255c9 + % TODO trattare qui ioctl_ficlonerange ? % TODO trattare qui close_range, vedi https://lwn.net/Articles/789023/ diff --git a/filedir.tex b/filedir.tex index 6577274..96c4b58 100644 --- a/filedir.tex +++ b/filedir.tex @@ -1,6 +1,6 @@ %% filedir.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", @@ -1182,6 +1182,9 @@ utilizzati solo in fase di montaggio: % * http://lwn.net/Articles/159077/ e % * Documentation/filesystems/sharedsubtree.txt +% TODO: (bassa priorità) trattare mount_setattr, vedi +% https://lwn.net/Articles/896255/ + % TODO: (bassa priorità) non documentati ma presenti in sys/mount.h: % * MS_POSIXACL % * MS_KERNMOUNT @@ -6262,6 +6265,8 @@ gestione delle quote è \funcd{quotactl}, ed il suo prototipo è: \end{funcproto} % TODO rivedere gli errori +% TODO aggiungere quotactl_fd introdotta con il kernel 5.14, vedi +% https://lwn.net/Articles/859679/ La funzione richiede che il filesystem sul quale si vuole operare, che deve essere specificato con il nome del relativo file di dispositivo nell'argomento diff --git a/fileio.tex b/fileio.tex index f630562..59a3614 100644 --- a/fileio.tex +++ b/fileio.tex @@ -1,6 +1,6 @@ -s%% fileio.tex (merge fileunix.tex - filestd.tex) +%% fileio.tex (merge fileunix.tex - filestd.tex) %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", @@ -557,6 +557,7 @@ escludere la possibilità di far esistere il file anche in un secondo tempo. % NOTE: per O_TMPFILE vedi: http://kernelnewbies.org/Linux_3.11 % https://lwn.net/Articles/558598/ http://lwn.net/Articles/619146/ +% https://lwn.net/Articles/896153/ \begin{table}[!htb] @@ -1959,6 +1960,9 @@ aggiuntivo sono \textit{system call}, ad esempio \func{faccessat} e aderenza allo standard POSIX.1-2008, dato che la \textit{system call} sottostante non prevede l'argomento \param{flags}. +% TODO: nel kernel 6.6 è stata introdotta fchmodat2 che risolve il problema +% appena illustrato + % TODO: aggiornare per via di faccessat2 aggiunta con il kernel 5.8 In tab.~\ref{tab:at-functions_constant_values} si sono elencati i valori diff --git a/gapil.tex b/gapil.tex index 3b1d0c9..81c00c5 100644 --- a/gapil.tex +++ b/gapil.tex @@ -1,6 +1,6 @@ %% gapil.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 Simone Piccardi. Permission is granted to %% copy, distribute and/or modify this document under the terms of the GNU Free %% Documentation License, Version 1.3 or any later version published by the %% Free Software Foundation; with the Invariant Sections being "Un preambolo", @@ -136,7 +136,7 @@ hyperfootnotes=false]{hyperref} \begin{quote} - Copyright \copyright\ 2000-2021 Simone Piccardi. Permission is granted to + Copyright \copyright\ 2000-2024 Simone Piccardi. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being ``Un preambolo'' diff --git a/intro.tex b/intro.tex index 4059f5e..74091fc 100644 --- a/intro.tex +++ b/intro.tex @@ -1,6 +1,6 @@ %% intro.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/ipc.tex b/ipc.tex index 7306d8e..415b2a2 100644 --- a/ipc.tex +++ b/ipc.tex @@ -1,6 +1,6 @@ %% ipc.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/macro.tex b/macro.tex index 3cd6b92..9ede6c4 100644 --- a/macro.tex +++ b/macro.tex @@ -1,6 +1,6 @@ %% macro.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/netlayer.tex b/netlayer.tex index 4ed5260..275b00d 100644 --- a/netlayer.tex +++ b/netlayer.tex @@ -1,6 +1,6 @@ %% netlayer.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/network.tex b/network.tex index dde8230..7672423 100644 --- a/network.tex +++ b/network.tex @@ -1,6 +1,6 @@ %% network.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/othersock.tex b/othersock.tex index 325fb0d..0f7b665 100644 --- a/othersock.tex +++ b/othersock.tex @@ -1,6 +1,6 @@ %% othersock.tex %% -%% Copyright (C) 2004-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2004-2024 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", @@ -801,6 +801,8 @@ stack dei protocolli. \subsection{I socket \textit{netlink}} \label{sec:socket_netlink} +Vedi \url{https://docs.kernel.org/next/userspace-api/netlink/index.html} + \subsection{I \textit{packet socket}} \label{sec:packet_socket} diff --git a/preambolo.tex b/preambolo.tex index 522eb13..0d51e0e 100644 --- a/preambolo.tex +++ b/preambolo.tex @@ -1,6 +1,6 @@ %% preambolo.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/pref.tex b/pref.tex index 4659e92..03e134f 100644 --- a/pref.tex +++ b/pref.tex @@ -1,6 +1,6 @@ %% pref.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/procadv.tex b/procadv.tex index a5ea67f..d8314d7 100644 --- a/procadv.tex +++ b/procadv.tex @@ -1360,6 +1360,10 @@ essere fornito in una forma di codice interpretabile fornito attraverso un socket o una \textit{pipe}, creati prima di lanciare il processo che eseguirà il codice non fidato. +% TODO: a partire dal kernel 6.6 è stato introdotto +% SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP that indicates that events from the +% watched process will be handled synchronously; that allows the kernel to +% schedule the two processes more efficiently (da LWN) % TODO a partire dal kernel 3.5 è stato introdotto la possibilità di usare un % terzo argomento se il secondo è SECCOMP_MODE_FILTER, vedi @@ -1565,6 +1569,10 @@ all'ordinario valore nullo (dato per implicito). %TODO: trattare PR_MPX_*_MANAGEMENT, dal 3.19, vedi % https://lwn.net/Articles/582712/ %TODO: trattare PR_*NO_NEW_PRIVS, dal 3.5 +%TODO: trattare il core scheduling dal 5.14, vedi +%https://lwn.net/Articles/780703/ e https://lwn.net/Articles/861251/ +%TODO: trattare PR_SPEC_L1D_FLUSH vedi https://git.kernel.org/linus/b7fe54f6c2d4 + \begin{basedescript}{\desclabelwidth{1.5cm}\desclabelstyle{\nextlinelabel}} \item[\constd{PR\_CAPBSET\_READ}] Controlla la disponibilità di una delle @@ -1902,6 +1910,10 @@ Introdotta a partire dal kernel 2.4.21, solo su PowerPC. % TODO documentare PR_SET_SYSCALL_USER_DISPATCH in 5.11, vedi % https://lwn.net/Articles/826313/ +% TODO documentare PR_SET_MDWE in 6.3, vedi +% https://git.kernel.org/linus/b507808ebce2 + + \label{sec:prctl_operation} \end{basedescript} diff --git a/process.tex b/process.tex index 57b8873..349806e 100644 --- a/process.tex +++ b/process.tex @@ -1,6 +1,6 @@ %% process.tex %% -%% Copyright (C) 2000-2019 by Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 by 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", diff --git a/prochand.tex b/prochand.tex index 3ee2344..e02f0fd 100644 --- a/prochand.tex +++ b/prochand.tex @@ -1,6 +1,6 @@ %% prochand.tex %% -%% Copyright (C) 2000-2019 by Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 by 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", diff --git a/ringraziamenti.tex b/ringraziamenti.tex index 6d4e77e..c5c75df 100644 --- a/ringraziamenti.tex +++ b/ringraziamenti.tex @@ -1,6 +1,6 @@ %% ringraziamenti.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/session.tex b/session.tex index 639cf0d..beb46bb 100644 --- a/session.tex +++ b/session.tex @@ -1,6 +1,6 @@ %% session.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", @@ -44,9 +44,9 @@ Originariamente si trattava di dispositivi specifici (i terminali seriali, se non addirittura le telescriventi). Oggi questa interfaccia viene in genere emulata o tramite programmi o con le cosiddette console virtuali associate a monitor e tastiera, ma esiste sempre la possibilità di associarla direttamente -ad alcuni dispositivi, come eventuali linee seriali, ed in certi casi, come -buona parte dei dispositivi embedded su cui gira Linux (come router, access -point, ecc.) questa resta anche l'unica opzione per una \textit{console} di +a dispositivi specifici lelinee seriali, che in certi casi, come avviene per +buona parte dei dispositivi embedded su cui gira Linux come router, access +point, ecc. sono l'unica opzione per una avere una \textit{console} di sistema. @@ -64,7 +64,7 @@ molti terminali in contemporanea da una singola postazione di lavoro, ma il sistema è nato prima dell'esistenza di tutto ciò. Il \textit{job control} è una caratteristica opzionale, introdotta in BSD -negli anni '80, e successivamente standardizzata da POSIX.1. La sua +negli anni '80, e successivamente standardizzata da POSIX.1; la sua disponibilità nel sistema è verificabile attraverso il controllo della macro \macro{\_POSIX\_JOB\_CONTROL}. In generale il \textit{job control} richiede il supporto sia da parte della shell (quasi tutte ormai lo hanno), che da parte @@ -562,7 +562,7 @@ terminati. L'organizzazione del sistema del job control è strettamente connessa alle modalità con cui un utente accede al sistema per dare comandi, collegandosi ad esso con un terminale, che sia questo realmente tale, come un VT100 collegato -ad una seriale o virtuale, come quelli associati a schermo e tastiera o ad una +ad una seriale, o virtuale, come quelli associati a schermo e tastiera o ad una connessione di rete. Dato che i concetti base sono gli stessi, e dato che alla fine le differenze sono nel dispositivo cui il kernel associa i file standard (vedi tab.~\ref{tab:file_std_files}) per l'I/O, tratteremo solo il caso @@ -695,12 +695,12 @@ Questi programmi, che devono essere eseguiti in modalità non interattiva e senza nessun intervento dell'utente, sono normalmente chiamati \textsl{demoni}, (o \textit{daemons}), nome ispirato dagli omonimi spiritelli della mitologia greca che svolgevano compiti che gli dei trovavano noiosi, di -cui parla anche Socrate (che sosteneva di averne uno al suo servizio). +cui parla anche Socrate, che sosteneva di averne uno al suo servizio. %TODO ricontrollare, i miei ricordi di filosofia sono piuttosto datati. Se però si lancia un programma demone dalla riga di comando in un sistema che -supporta, come Linux, il \textit{job control} esso verrà comunque associato ad +supporta il \textit{job control} come Linux, esso verrà comunque associato ad un terminale di controllo e mantenuto all'interno di una sessione, e anche se può essere mandato in background e non eseguire più nessun I/O su terminale, si avranno comunque tutte le conseguenze che abbiamo trattato in @@ -823,7 +823,7 @@ differenti meccanismi come: le modalità con cui queste azioni vengono realizzate dipendono ovviamente dal demone che si usa, per la gestione del quale si rimanda ad un testo di amministrazione di sistema.\footnote{l'argomento è ad esempio coperto dal - capitolo 3.2.3 si \cite{AGL}.} + capitolo 3.2.3 di \cite{AGL}.} La \acr{glibc} definisce una serie di funzioni standard con cui un processo può accedere in maniera generica al servizio di \textit{syslog}, che però @@ -1270,9 +1270,9 @@ al di fuori di questo. \label{sec:sess_terminal_io} Benché come ogni altro dispositivo i terminali siano accessibili come file, -essi hanno assunto storicamente, essendo stati a lungo l'unico modo di -accedere al sistema, una loro rilevanza specifica, che abbiamo già avuto modo -di incontrare nella precedente sezione. +essendo stati a lungo l'unico modo di accedere al sistema essi hanno assunto +storicamente una loro rilevanza specifica, che abbiamo già avuto modo di +incontrare nella precedente sezione. Esamineremo qui le peculiarità dell'I/O eseguito sui terminali, che per la loro particolare natura presenta delle differenze rispetto ai normali file su diff --git a/signal.tex b/signal.tex index 63a9400..7b6cb8e 100644 --- a/signal.tex +++ b/signal.tex @@ -1,6 +1,6 @@ %% signal.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", @@ -2594,12 +2594,16 @@ prototipo è: {La funzione ritorna $0$ in caso di successo e $-1$ per un errore, nel qual caso \var{errno} assumerà uno dei valori: \begin{errlist} - \item[\errcode{EFAULT}] si sono specificati indirizzi non validi. - \item[\errcode{EINVAL}] si è specificato un numero di segnale invalido. + \item[\errcode{EFAULT}] l'indirizzo di \param{mask} non è valido. + \item[\errcode{EINTR}] la funzione è stata interrotta da un segnale. \end{errlist} } \end{funcproto} +La funzione imposta la maschera dei segnali indicata da \param{mask} e pone in +attesa il processo. Ritorna solo con la ricezione di un segnale, con un errore +di \errval{EINTR}, a meno che il segnale non termini il processo. + Come esempio dell'uso di queste funzioni proviamo a riscrivere un'altra volta l'esempio di implementazione di \code{sleep}. Abbiamo accennato in sez.~\ref{sec:sig_sigaction} come con \func{sigaction} sia possibile bloccare @@ -3017,11 +3021,10 @@ prima di queste è \funcd{sigwait}, il cui prototipo è: \fdecl{int sigwait(const sigset\_t *set, int *sig)} \fdesc{Attende la ricezione di un segnale.} } -{La funzione ritorna $0$ in caso di successo e $-1$ per un errore, nel qual - caso \var{errno} assumerà uno dei valori: +{La funzione ritorna $0$ in caso di successo ed un valore positivo in caso di + errore con valore secondo la lista seguente: \begin{errlist} - \item[\errcode{EINTR}] la funzione è stata interrotta. - \item[\errcode{EINVAL}] si è specificato un valore non valido per + \item[\errcode{EINVAL}] \param{set} contiene un numero di segnale non valido \end{errlist} ed inoltre \errval{EFAULT} nel suo significato generico.} \end{funcproto} @@ -3095,14 +3098,6 @@ che venga eseguita l'azione predefinita, devono essere mascherati per tutti i \textit{thread}, compreso quello dedicato alla gestione, che potrebbe riceverlo fra due chiamate successive. -Come esempio elementare dell'uso dei segnali \textit{real-time}, e della -possibilità di inviare informazioni al gestore degli stessi con -\func{sigqueue}, si è riportato in fig.~\ref{fig:sig_rtsival_main} il corpo -principale di un programma elementare che legge dal terminale un valore -numerico, ed utilizza un segnale \textit{real-time} per inviarlo al gestore -dello stesso. Si sono trascurati i controlli dei valori di ritorno delle varie -funzioni per brevità. - \begin{figure}[!htb] \footnotesize \centering \begin{minipage}[c]{\codesamplewidth} @@ -3114,11 +3109,19 @@ funzioni per brevità. \label{fig:sig_rtsival_main} \end{figure} +Come esempio elementare dell'uso dei segnali \textit{real-time}, e della +possibilità di inviare informazioni al gestore degli stessi con +\func{sigqueue}, si è riportato in fig.~\ref{fig:sig_rtsival_main} il corpo +principale di un programma elementare che legge dal terminale un valore +numerico, ed utilizza un segnale \textit{real-time} per inviarlo al gestore +dello stesso. Nel codice sono stati trascurati i controlli dei valori di +ritorno delle varie funzioni per mantenere la brevità dell'esempio. + Dopo aver definito (\texttt{\small 5}) una variabile \var{value} di tipo -\type{sigval\_t} per inviare i dati, ed aver opportunamente scelto +\type{sigval\_t} per poter inviare i dati, e dopo aver opportunamente scelto (\texttt{\small 6}) per \var{signo} un segnale \textit{real-time}, la parte iniziale del programma (\texttt{\small 8--11}) installa il relativo gestore -(la cui definizione è riportata in fig.~\ref{fig:sig_rtsival_handl}), dopo di +(la cui definizione è riportata in fig.~\ref{fig:sig_rtsival_handl}). Dopo di che il programma si pone in un ciclo infinito (\texttt{\small 14--27}) in cui prima (\texttt{\small 15--20}) legge in buffer dallo \textit{standard input} una stringa immessa dall'utente, terminandola opportunamente (\texttt{\small @@ -3128,6 +3131,10 @@ conversione ha successo e \texttt{value.sival\_int} è positivo) invia a se stesso (\texttt{\small 23}) il segnale \textit{real-time}, altrimenti stampa un avviso (\texttt{\small 24}). +Alla ricezione del segnale il gestore si limita a stampare alcune delle +informazioni ricevute nella struttura \struct{sigval\_t}, ed in particolare +(\texttt{\small 5}) stampa tramite il valore del campo \var{si\_value} il +numero che gli è stato inviato da \func{sigqueue}. \begin{figure}[!htb] \footnotesize \centering @@ -3135,14 +3142,12 @@ un avviso (\texttt{\small 24}). \includecodesample{listati/rtsigvalsend_handl.c} \end{minipage} \normalsize - \caption{Codice del gestore.} + \caption{Codice del gestore usato dal programma di + fig.~\ref{fig:sig_rtsival_main}.} \label{fig:sig_rtsival_handl} \end{figure} - - - \subsection{La gestione avanzata delle temporizzazioni} \label{sec:sig_timer_adv} @@ -3191,20 +3196,6 @@ alta definizione però erano già presenti, essendo stata introdotte insieme ad altre funzioni per il supporto delle estensioni \textit{real-time} con il rilascio del kernel 2.6, ma la risoluzione effettiva era nominale. -A tutte le implementazioni che si rifanno a queste estensioni è richiesto di -disporre di una versione \textit{real-time} almeno per l'orologio generale di -sistema, quello che mantiene il \textit{calendar time} (vedi -sez.~\ref{sec:sys_time_base}), che in questa forma deve indicare il numero di -secondi e nanosecondi passati a partire dal primo gennaio 1970 (\textit{The - Epoch}). Si ricordi infatti che l'orologio ordinario usato dal -\textit{calendar time} riporta solo un numero di secondi, e che la risoluzione -effettiva normalmente non raggiunge il nanosecondo (a meno di hardware -specializzato). Oltre all'orologio generale di sistema possono essere -presenti altri tipi di orologi \textit{real-time}, ciascuno dei quali viene -identificato da un opportuno valore di una variabile di tipo -\type{clockid\_t}; un elenco di quelli disponibili su Linux è riportato in -tab.~\ref{tab:sig_timer_clockid_types}. - \begin{table}[htb] \footnotesize \centering @@ -3262,6 +3253,19 @@ tab.~\ref{tab:sig_timer_clockid_types}. \label{tab:sig_timer_clockid_types} \end{table} +A tutte le implementazioni che si rifanno a queste estensioni è richiesto di +disporre di una versione \textit{real-time} almeno per l'orologio generale di +sistema, quello che mantiene il \textit{calendar time} (vedi +sez.~\ref{sec:sys_time_base}), che in questa forma deve indicare il numero di +secondi e nanosecondi passati a partire dal primo gennaio 1970 (\textit{The + Epoch}). Si ricordi infatti che l'orologio ordinario usato dal +\textit{calendar time} riporta solo un numero di secondi, e che la risoluzione +effettiva normalmente non raggiunge il nanosecondo (a meno di hardware +specializzato). Oltre all'orologio generale di sistema possono essere +presenti altri tipi di orologi \textit{real-time}, ciascuno dei quali viene +identificato da un opportuno valore di una variabile di tipo +\type{clockid\_t}; un elenco di quelli disponibili su Linux è riportato in +tab.~\ref{tab:sig_timer_clockid_types}. % TODO: dal 4.17 CLOCK_MONOTONIC e CLOCK_BOOTTIME sono identici vedi % https://lwn.net/Articles/751651/ e @@ -3331,17 +3335,17 @@ stata inizializzata con il valore che si vuole impostare sull'orologio, mentre per \func{clock\_gettime} verrà restituito al suo interno il valore corrente dello stesso. -Si tenga presente inoltre che per eseguire un cambiamento sull'orologio -generale di sistema \const{CLOCK\_REALTIME} occorrono i privilegi -amministrativi;\footnote{ed in particolare la \textit{capability} - \const{CAP\_SYS\_TIME}.} inoltre ogni cambiamento ad esso apportato non avrà -nessun effetto sulle temporizzazioni effettuate in forma relativa, come quelle -impostate sulle quantità di \textit{process time} o per un intervallo di tempo -da trascorrere, ma solo su quelle che hanno richiesto una temporizzazione ad -un istante preciso (in termini di \textit{calendar time}). Si tenga inoltre -presente che nel caso di Linux \const{CLOCK\_REALTIME} è l'unico orologio per -cui si può effettuare una modifica, infatti nonostante lo standard preveda la -possibilità di modifiche anche per \const{CLOCK\_PROCESS\_CPUTIME\_ID} e +Per eseguire un cambiamento sull'orologio generale di sistema +\const{CLOCK\_REALTIME} occorrono i privilegi amministrativi;\footnote{ed in + particolare la \textit{capability} \const{CAP\_SYS\_TIME}.} e che ogni +cambiamento ad esso apportato non avrà nessun effetto sulle temporizzazioni +effettuate in forma relativa, come quelle impostate sulle quantità di +\textit{process time} o per un intervallo di tempo da trascorrere, ma solo su +quelle che hanno richiesto una temporizzazione ad un istante preciso (in +termini di \textit{calendar time}). Si tenga inoltre presente che nel caso di +Linux \const{CLOCK\_REALTIME} è l'unico orologio per cui si può effettuare una +modifica, infatti nonostante lo standard preveda la possibilità di modifiche +anche per \const{CLOCK\_PROCESS\_CPUTIME\_ID} e \const{CLOCK\_THREAD\_CPUTIME\_ID}, il kernel non le consente. Oltre alle due funzioni precedenti, lo standard POSIX prevede una terza @@ -3377,16 +3381,15 @@ voglia utilizzare nelle funzioni di impostazione che non corrisponda ad un multiplo intero di questa risoluzione, sarà troncato in maniera automatica. Gli orologi elencati nella seconda sezione di -tab.~\ref{tab:sig_timer_clockid_types} sono delle estensioni specifiche di -Linux, create per rispondere ad alcune esigenze specifiche, come quella di -tener conto di eventuali periodi di sospensione del sistema, e presenti solo -nelle versioni più recenti del kernel. In particolare gli ultimi due, -contraddistinti dal suffisso \texttt{\_ALARM}, hanno un impiego particolare, -derivato dalle esigenze emerse con Android per l'uso di Linux sui cellulari, -che consente di creare timer che possono scattare, riattivando il sistema, -anche quando questo è in sospensione. Per il loro utilizzo è prevista la -necessità di una capacità specifica, \const{CAP\_WAKE\_ALARM} (vedi -sez.~\ref{sec:proc_capabilities}). +tab.~\ref{tab:sig_timer_clockid_types} sono estensioni specifiche di Linux +presenti solo nelle versioni più recenti del kernel, create per rispondere ad +alcune esigenze specifiche come quella di tener conto di eventuali periodi di +sospensione del sistema. In particolare gli ultimi due, contraddistinti dal +suffisso \texttt{\_ALARM}, hanno un impiego particolare derivato dalle +esigenze emerse con Android per l'uso di Linux sui cellulari, che consente di +creare timer che possono scattare, riattivando il sistema, anche quando questo +è in sospensione. Per il loro utilizzo è prevista la necessità di una capacità +specifica, \const{CAP\_WAKE\_ALARM} (vedi sez.~\ref{sec:proc_capabilities}). Si tenga presente inoltre che con l'introduzione degli \textit{high resolution timer} i due orologi \const{CLOCK\_PROCESS\_CPUTIME\_ID} e @@ -3888,10 +3891,10 @@ anch'essa introdotta dallo standard POSIX.1, il suo prototipo è: La funzione permette di ricavare quali sono i segnali pendenti per il processo in corso, cioè i segnali che sono stati inviati dal kernel ma non sono stati ancora ricevuti dal processo in quanto bloccati. Non esiste una funzione -equivalente nella vecchia interfaccia, ma essa è tutto sommato poco utile, -dato che essa può solo assicurare che un segnale è stato inviato, dato che -escluderne l'avvenuto invio al momento della chiamata non significa nulla -rispetto a quanto potrebbe essere in un qualunque momento successivo. +equivalente nella vecchia interfaccia, ma essa, potendo solo assicurare che un +segnale è stato inviato, è tutto sommato poco utile dato che escluderne +l'avvenuto invio al momento della chiamata non significa nulla rispetto a +quanto potrebbe accadere in un qualunque momento successivo. Una delle caratteristiche di BSD, disponibile anche in Linux, è la possibilità di usare uno \textit{stack} alternativo per i segnali; è cioè possibile fare diff --git a/sockadv.tex b/sockadv.tex index a9e4cd5..8eede04 100644 --- a/sockadv.tex +++ b/sockadv.tex @@ -1,6 +1,6 @@ %% sockadv.tex %% -%% Copyright (C) 2004-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2004-2024 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", diff --git a/sockctrl.tex b/sockctrl.tex index 9d5279e..19f9ddc 100644 --- a/sockctrl.tex +++ b/sockctrl.tex @@ -1,6 +1,6 @@ %% sockctrl.tex %% -%% Copyright (C) 2004-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2004-2024 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 "Prefazione", @@ -2669,8 +2669,10 @@ tab.~\ref{tab:sock_opt_socklevel} sul significato delle varie opzioni: \item[\constd{SO\_TYPE}] questa opzione permette di leggere il tipo di socket su cui si opera; funziona solo con \func{getsockopt}, ed utilizza per \param{optval} un intero in cui verrà restituito il valore numerico che lo - identifica (ad esempio \const{SOCK\_STREAM}). - + identifica (ad esempio \const{SOCK\_STREAM}). + +% TODO verificare IP_LOCAL_PORT_RANGE, aggiunta con il 6.3 +% vedi https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=91d0b78c5177 \end{basedescript} diff --git a/socket.tex b/socket.tex index b01ff3a..51bdad7 100644 --- a/socket.tex +++ b/socket.tex @@ -1,6 +1,6 @@ %% socket.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/sources/sigwait.c b/sources/sigwait.c new file mode 100644 index 0000000..7dcc983 --- /dev/null +++ b/sources/sigwait.c @@ -0,0 +1,66 @@ +/* sigwait.c + * + * Copyright (C) 2021 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 sigwait.c: + * Test program for sigwait function + * + * Author: Simone Piccardi + * Nov. 2021 + * + ****************************************************************/ +/* + * Include needed headers + */ +#define _GNU_SOURCE +#include /* unix standard library */ +#include /* signal constants, types and functions */ +#include /* error definitions and routines */ +#include /* C standard library */ +#include /* unix standard library */ +#include /* standard I/O library */ +#include /* C strings library */ + +int main(int argc, char *argv[]) +{ +/* + * Variables definition + */ + int i; + pid_t pid = 0; + int sig,res; + sigset_t set; + + sigemptyset(&set); + sigaddset(&set, SIGALRM); +// while (1) { + res=sigwait(&set, &sig); + printf("Sig was %d", sig); + if ( res > 0) { + printf("Errno was %d", errno); + perror("errore"); + printf("Result was %d", res); + printf("Error by res was %s", strerror(res)); + exit(11); + } else { + printf("Result was %d", res); + printf("Normal exit"); + } +// } +} diff --git a/system.tex b/system.tex index a761b4d..671b102 100644 --- a/system.tex +++ b/system.tex @@ -1,6 +1,6 @@ %% system.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/tcpsock.tex b/tcpsock.tex index 5951a91..525867e 100644 --- a/tcpsock.tex +++ b/tcpsock.tex @@ -1,6 +1,6 @@ %% tcpsock.tex %% -%% Copyright (C) 2000-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2000-2024 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", diff --git a/thread.tex b/thread.tex index 62f4dfd..b067920 100644 --- a/thread.tex +++ b/thread.tex @@ -1,6 +1,6 @@ %% thread.tex %% -%% Copyright (C) 2007-2019 Simone Piccardi. Permission is granted to +%% Copyright (C) 2007-2024 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", diff --git a/trasplayer.tex b/trasplayer.tex index 97b0efb..4493730 100644 --- a/trasplayer.tex +++ b/trasplayer.tex @@ -1,6 +1,6 @@ %% tcpprot.tex %% -%% Copyright (C) 2002-2019 Simone Piccardi. Permission is granted to copy, +%% Copyright (C) 2002-2024 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",