\documentclass[crop,tikz]{standalone} \usetikzlibrary{arrows.meta, backgrounds, positioning, fit, petri} \begin{document} \begin{tikzpicture}[ auto, node distance=1.3cm, on grid, >={Stealth[round]}, bend angle=45, every place/.style={minimum size=6mm, thick, draw=blue!75, fill=blue!20}, every transition/.style={thick, draw=black!75, fill=black!20} ] \node[place, tokens=5] (waiting) {}; \node[place] (critical) [below=of waiting] {}; \node[place] (semaphore) [below=of critical] {}; \node[transition] (leave critical) [right=of critical] {} edge[pre] (critical) edge[post] node[auto,swap] {2} (waiting) edge[pre] (semaphore); \node[transition] (enter critical) [left=of critical] {} edge[post] (critical) edge[pre] (waiting) edge[post] (semaphore); \begin{scope}[on background layer] \node[fill=black!25, fit=(waiting) (critical) (semaphore) (leave critical) (enter critical)] {}; \end{scope} \end{tikzpicture} \end{document}