I am trying to create a gantt chart for my thesis on blocking analysis. I know of the pgfgantt package for generating gantt charts. But this package generates charts for normal schedules, what I need is gantt charts specifically for blocking analysis, like those used in Operating Systems text books.

Here is an example of what I need:

Gantt Chart for CPU scheduling

How can I make a chart similar to this one using pdflatex? I don't mind using pgfgantt either, except I don't see how it can render something like this.

  • It's not that hard to do it by hand with TikZ. However, if you're going to do a lot of them it could be tedious. Do you need a package like pgfgantt or you may give it a try to make it by hand?
    – Nico
    Commented Feb 7, 2014 at 14:03
  • 1
    Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. Commented Feb 7, 2014 at 14:09
  • 1
    @nico: My problem with pgfgantt is I couldn't find anything in the documentation which would allow diagrams with blocking, preemption, etc to be drawn. I may give it a try by hand using TikZ but as you say it will be tedious since I will have loads of such charts to draw.
    – darnir
    Commented Feb 7, 2014 at 15:17
  • @MartinSchröder: Thanks! But my problem is that I have no MWE as of now. Unless I draw it by hand through TikZ, which would be too tedious. I haven't tried using pgfgantt since I couldn't find anything in the documentation which would lead me to believe that it can be done
    – darnir
    Commented Feb 7, 2014 at 15:19
  • 1
    The package rtsched can be used to create simple process scheduling diagrams, but I don't know if it is possible to do such a "complex" chart. See the package documentation for more details!
    – user99748
    Commented Mar 2, 2016 at 22:00

1 Answer 1


I could not resist:



  midstroke/.style={path picture={\draw (path picture bounding box.west) -- (path picture bounding box.east);}},
  divided/.style={path picture={\draw (path picture bounding box.north west) -- (path picture bounding box.south east);}}]
 \foreach\x in {0,...,\gridw}{
  \draw[black!25] ({\x+1},0) -- ++(0,1);
   \draw ({\x+1},0) coordinate (c\x) -- ({\x+1},.5);
   \node at ([yshift=-5]c\x.south) {\x};
   \draw ({\x+1},0) coordinate (c\x) -- ({\x+1},.25);
 \draw[<->,>={Latex[open]}] (0,{\procs+1}) -- (0,0) -- ({\gridw+2},0);%
 \draw[black!25] (0,\procs) coordinate (r\procs) -- ({\gridw+1},\procs);
 \foreach\x in {0,...,\gridw}
  \draw[black!25] ({\x+1},\procs) -- ++(0,1);
   \node[anchor=east] at ([yshift=5,xshift=-25]r\procs.west) {$#1$:};
  \draw[black!25] (r\procs.west) -- ++(-5,0);
 \node[anchor=east] at ([yshift=5,xshift=0]r\procs.west) {$#2$};

 \foreach\x/\y in {#2}
  \draw[processbox,#1] ({\x+1},0) coordinate (a) rectangle ({\y+1},.5);
 \draw[->] (a) -- ++(0,.9);

 \foreach\x/\y in {#2}
  \draw[pendingbox,#1] ({\x+1},.1) rectangle ({\y+1},.4);

 \foreach\x/\y in {#2}
  \draw[processbox,divided] ({\x+1},0) rectangle ({\y+1},.5) 
   node[anchor=north east,inner sep=1pt,xshift=1pt] {\tiny $#1$};

 \foreach\x/\y in {#2}
  \draw[processbox,#1] ({\x+1},0) rectangle ({\y+1},.5) coordinate (a);
 \draw[-|] (a) -- ++(0,.25);

 \draw[black!25] ([yshift=15]r\procs.west) coordinate (g0) -- ++(-5,0);
 \path (g0) -- coordinate[midway] (m) (r\procs.west);
 \draw[decorate,decoration={brace}] ([xshift=-22]g0) -- ([xshift=-22,yshift=10]r\procs.west);
 \node[anchor=east] at ([yshift=5,xshift=-25]m) {$\processgroupname$:};








enter image description here

  • 1
    \setcounter{procs}{0} should be added to the beginning of the definition of the schedulechart environment
    – Mike D.
    Commented Aug 2, 2023 at 14:40
  • @MikeD. Good point! If you want to use the diagram mulitple times, this is essential, of course! Thank you! Added Commented Aug 2, 2023 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .