From: Jim Huang Date: Fri, 23 Jul 2021 06:33:30 +0000 (+0800) Subject: Merge pull request #2 from 25077667/master X-Git-Tag: latest~233 X-Git-Url: https://www.ivnss.com/gitweb/?a=commitdiff_plain;h=40ae17c1f8ea8d2f716cfbec75cc6b018a38d6f3;p=lkmpg Merge pull request #2 from 25077667/master Redraw figure: seq_file --- 40ae17c1f8ea8d2f716cfbec75cc6b018a38d6f3 diff --cc lkmpg.tex index ebe2089,7595f2e..a5d9e60 --- a/lkmpg.tex +++ b/lkmpg.tex @@@ -783,10 -740,26 +793,26 @@@ formating a /proc file for output. It' A sequence begins with the call of the function start(). If the return is a non NULL value, the function next() is called. This function is an iterator, the goal is to go thought all the data. Each time next() is called, the function show() is also called. It writes data values in the buffer read by the user. The function next() is called until it returns NULL. The sequence ends when next() returns NULL, then the function stop() is called. -BE CARREFUL: when a sequence is finished, another one starts. That means that at the end of function stop(), the function start() is called again. This loop finishes when the function start() returns NULL. You can see a scheme of this in the figure "How seq\_file works". +BE CAREFUL: when a sequence is finished, another one starts. That means that at the end of function stop(), the function start() is called again. This loop finishes when the function start() returns NULL. You can see a scheme of this in the figure "How seq\_file works". \begin{center} - \includegraphics[width=.9\linewidth]{img/seq_file.png} + \begin{tikzpicture}[node distance=2cm, thick] + \node (start) [startstop] {start() treatment}; + \node (branch1) [decision, below of=start, yshift=-1cm] {return is NULL?}; + \node (emptynode) [right of=branch1, xshift=2cm] {Yes}; + \node (next) [process, below of=branch1, yshift=-1cm] {next() treatment}; + \node (branch2) [decision, below of=next, yshift=-1cm] {return is NULL?}; + \node (stop) [startstop, below of=branch2, yshift=-1cm] {stop() treatment}; + + + \draw [->] (start) -- (branch1); + \draw [->] (branch1) -- node[anchor=east] {} (emptynode); + \draw [->] (branch1) -- node[left=2em, anchor=south] {No} (next); + \draw [->] (next) -- (branch2); + \draw [->] (branch2.west) to [out=135, in=-135, bend left=45] node [left] {No} (next.west); + \draw [->] (branch2) -- node[left=2em, anchor=south] {Yes} (stop); + \draw [->] (stop.west) to [out=135, in=-135] node [left] {} (start.west); + \end{tikzpicture} \end{center} Seq\_file provides basic functions for proc\_ops, as seq\_read, seq\_lseek, and some others. But nothing to write in the /proc file. Of course, you can still use the same way as in the previous example.