defense/src/fig/context/threadpool.tex

52 lines
2.0 KiB
TeX

\begin{tikzpicture}
\input{src/tikz/exec}
% pool
\begin{scope}[start chain=circle placed {at=(\tikzchaincount*72+18:.8)}]
\foreach \i in {0,...,4} {
\node[on chain,exec/thread=black] (t\i) {t\textsubscript{\i}};
}
\end{scope}
\path (t0) |- node[pos=.2,exec/thread=black]{t\textsubscript{k}} ($(t2)!.5!(t3)$);
\begin{scope}[on background layer]
\node[exec/pool=(t0)(t1)(t2)(t3)(t4)](pool){};
\end{scope}
\path (pool.north west) -- node[above]{\en{pool}} (pool.north east);
\draw[decorate,decoration={brace,amplitude=4pt,raise=3pt,mirror}]
(pool.north west) -- node[left=5pt]{$k+1$ \en{threads}} (pool.south west);
% fifo
\node[exec/fifonode,draw=none,fill=none,above=of t0](fifo3) {\dots};
\begin{scope}[node distance=-.1mm,start chain=fifo]
\foreach \i/\p/\n in {2/3/n-2,1/2/n-1,0/1/n} { \node[exec/fifonode,left=of fifo\p] (fifo\i) {$m_{\n}$}; }
\foreach \i/\p/\n in {4/3/2,5/4/1,6/5/0} { \node[exec/fifonode,right=of fifo\p] (fifo\i) {$m_{\n}$}; }
\end{scope}
\draw[-,densely dotted] ([yshift=-.05mm]fifo3.north west) -- ([yshift=-.05mm]fifo3.north east);
\draw[-,densely dotted] ([yshift=+.05mm]fifo3.south west) -- ([yshift=+.05mm]fifo3.south east);
\node[exec/fit=(fifo0)(fifo6),fit margins={left=2.25mm},dash phase=2](mutex) {};
\path (mutex.north west)
-- node[above](lblmutex){accès en section critique (\en{mutex}) à la file de tâches} (mutex.north east);
% arrows
\draw[-] ([xshift=-8mm]fifo0.west) -- (fifo0.west);
\draw[->,rounded corners] (fifo6.east) -- ++(4mm,0) |- (pool.east);
\coordinate (mutexeast) at ([xshift=3mm]mutex.east);
\node[exec/fit=(lblmutex)(mutex)(pool)(mutexeast),densely dashed](threadpool) {};
\path (threadpool.north west) -- node[above]{\en{thread pool}} (threadpool.north east);
% background
\begin{scope}[on background layer]
\node[fit=(threadpool),inner sep=3ex,rectangle,rounded corners,fill=white,opacity=.95]{};
\end{scope}
% fix thread pool border
\begin{scope}[on background layer]
\node[exec/pool=(t0)(t1)(t2)(t3)(t4)]{};
\end{scope}
\end{tikzpicture}