X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=process.tex;h=30913ae8d9df5c24e209c12e5c64b173a0a8e3c2;hp=b5cfe14b9f019a61b22cff38013a2d88cc09b5a3;hb=3da7aa8ec1541a808985971cf3814baa83f32f69;hpb=886e1105f5b014b7984a8416d6a8101259af16d6 diff --git a/process.tex b/process.tex index b5cfe14..30913ae 100644 --- a/process.tex +++ b/process.tex @@ -50,7 +50,7 @@ specificato il flag \texttt{-static} durante la compilazione, tutti i programmi in Linux sono incompleti e necessitano di essere \textsl{collegati} alle librerie condivise quando vengono avviati. La procedura è controllata da alcune variabili di ambiente e dal contenuto di \conffile{/etc/ld.so.conf}. I -dettagli sono riportati nella man page di \cmd{ld.so}. +dettagli sono riportati nella pagina di manuale di \cmd{ld.so}. Il sistema fa partire qualunque programma chiamando la funzione \func{main}; sta al programmatore chiamare così la funzione principale del programma da cui @@ -234,7 +234,44 @@ normalmente un programma \begin{figure}[htb] \centering - \includegraphics[width=9cm]{img/proc_beginend} +% \includegraphics[width=9cm]{img/proc_beginend} + \begin{tikzpicture}[>=stealth] + \filldraw[fill=black!35] (-0.3,0) rectangle (12,1); + \draw(5.5,0.5) node {\large{kernel}}; + + \filldraw[fill=black!15] (1.5,2) rectangle (4,3); + \draw (2.75,2.5) node {\texttt{ld-linux.so}}; + \draw [->] (2.75,1) -- (2.75,2); + \draw (2.75,1.5) node [anchor=west]{\texttt{exec}}; + + \filldraw[fill=black!15,rounded corners] (1.5,4) rectangle (4,5); + \draw (2.75,4.5) node {\texttt{main}}; + + \draw [<->, dashed] (2.75,3) -- (2.75,4); + \draw [->] (1.5,4.5) -- (0.3,4.5) -- (0.3,1); + \draw (0.9,4.5) node [anchor=south] {\texttt{\_exit}}; + + \filldraw[fill=black!15,rounded corners] (1.5,6) rectangle (4,7); + \draw (2.75,6.5) node {\texttt{funzione}}; + + \draw [<->, dashed] (2.75,5) -- (2.75,6); + \draw [->] (1.5,6.5) -- (0.05,6.5) -- (0.05,1); + \draw (0.9,6.5) node [anchor=south] {\texttt{\_exit}}; + + \draw (6.75,4.5) node (exit) [rectangle,fill=black!15,minimum width=2.5cm,minimum height=1cm,rounded corners, draw]{\texttt{exit}}; + + \draw[->] (4,6.5) -- node[anchor=south west]{\texttt{exit}} (exit); + \draw[->] (4,4.5) -- node[anchor=south]{\texttt{exit}} (exit); + \draw[->] (exit) -- node[anchor=east]{\texttt{\_exit}}(6.75,1); + + \draw (10,4.5) node (exithandler1) [rectangle,fill=black!15,rounded corners, draw]{exit handler}; + \draw (10,5.5) node (exithandler2) [rectangle,fill=black!15,rounded corners, draw]{exit handler}; + \draw (10,3.5) node (stream) [rectangle,fill=black!15,rounded corners, draw]{chiusura stream}; + + \draw[<->, dashed] (exithandler1) -- (exit); + \draw[<->, dashed] (exithandler2) -- (exit); + \draw[<->, dashed] (stream) -- (exit); + \end{tikzpicture} \caption{Schema dell'avvio e della conclusione di un programma.} \label{fig:proc_prog_start_stop} \end{figure} @@ -406,7 +443,7 @@ seguenti segmenti: automaticamente il codice necessario, seguendo quella che viene chiamata una \textit{calling convention}; quella standard usata con il C ed il C++ è detta \textit{cdecl} e prevede che gli argomenti siano caricati nello - stack fal chiamante da destra a sinistra, e che si il chimante stesso ad + stack dal chiamante da destra a sinistra, e che si il chiamante stesso ad eseguire la ripulitura dello stack al ritorno della funzione, se ne possono però utilizzare di alternative (ad esempio nel pascal gli argomenti sono inseriti da sinistra a destra ed è compito del chiamato @@ -420,7 +457,27 @@ seguenti segmenti: \begin{figure}[htb] \centering - \includegraphics[height=12cm]{img/memory_layout} +% \includegraphics[height=12cm]{img/memory_layout} + \begin{tikzpicture} + \draw (0,0) rectangle (4,1); + \draw (2,0.5) node {text}; + \draw (0,1) rectangle (4,2.5); + \draw (2,1.75) node {dati inizializzati}; + \draw (0,2.5) rectangle (4,5); + \draw (2,3.75) node {dati non inizializzati}; + \draw (0,5) rectangle (4,9); + \draw[dashed] (0,6) -- (4,6); + \draw[dashed] (0,8) -- (4,8); + \draw (2,5.5) node {heap}; + \draw (2,8.5) node {stack}; + \draw [->] (2,6) -- (2,6.5); + \draw [->] (2,8) -- (2,7.5); + \draw (0,9) rectangle (4,10); + \draw (2,9.5) node {environment}; + \draw (4,0) node [anchor=west] {\texttt{0x08000000}}; + \draw (4,5) node [anchor=west] {\texttt{0x08xxxxxx}}; + \draw (4,9) node [anchor=west] {\texttt{0xC0000000}}; + \end{tikzpicture} \caption{Disposizione tipica dei segmenti di memoria di un processo.} \label{fig:proc_mem_layout} \end{figure} @@ -1712,7 +1769,8 @@ dichiarandole tutte come \direct{volatile}.\footnote{la direttiva % LocalWords: clearenv libc value overwrite string reference result argument % LocalWords: socket variadic ellipsis header stdarg execl self promoting last % LocalWords: float double short register type dest src extern setjmp jmp buf -% LocalWords: env return if while sottoprocesso Di +% LocalWords: env return if while Di page cdecl +% LocalWords: environment %%% Local Variables: %%% mode: latex