如何绘制进程调度方案?

如何绘制进程调度方案?

我想知道是否有可能在 Latex 中绘制类似下面的内容。如果可以,我需要使用哪种包?

一个例子:预定的进程

谢谢!

答案1

TiKZ你可以从类似的东西开始

\documentclass[tikz,border=2mm]{standalone}

\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}[x=1cm, y=-1mm, font=\sffamily, >=Latex,
    burst/.style 2 args={draw,rounded corners,anchor=north west, minimum width=1cm, 
                         minimum height=#2mm, name=n#1, node contents=$n_{#1}$, inner sep=0pt}]

\draw (0,0) -- (0,90);
\foreach \i in {0,10,20,...,90}
    \draw (0,\i) node[left] {\i}--++(0:.3);

\foreach \i [count=\p] in {1,3,5}
{
\draw[dashed] (\i,0) rectangle ++(1,90);
\node[above,xshift=0.5cm] at (\i,0) {P\p};
}

\path (1,28) node[burst={2}{12}];
\path (1,57) node[burst={8}{7}];

\foreach \i/\j/\k in {4/8/18, 6/18/26,9/12/55,10/6/74}
    \path (3,\k) node[burst={\i}{\j}];

\foreach \i/\j/\k in {1/10/0, 3/20/10,5/8/30,7/12/38}
    \path (5,\k) node[burst={\i}{\j}];

\draw[->] (n1.south west) to[out=190,in=60] (n2.north east);
\draw[->] (n1.south west) -- (n4.north east);
\draw[->] (n1.south west) -- (n6.north east);
\draw[->] (n7.south west) -- (n10.north east);
\draw[->] (n4.south west) -- (n8.north east);
\draw[->] (n6.south west) -- (n8.north east);
\draw[->] (n2.south east) -- (n9.north west);
\draw[->] (n8.south east) -- (n10.north west);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容