So, despite the occasional mocking from my friends, I continue to write presentations in Latex using prosper and pstricks, hoping that when the time comes I'll be able to save the day. In this case I wanted to create images that exhibit the dining philosophers problem for a presentation about synchronization in multithreading environments.

Here's one that exhibits a deadlock: (L and W stands for Locked and Waiting respectively)

deadlock in dining philosophers

And here's the Latex code:




    \pnode(6, 5){O} % center

    % philosophers and forks
	% Philosophers
        \pnode([nodesep=4, angle=\arabic{degp}]O){P\idx}
	% Forks
        \psline([nodesep=3.8, angle=\arabic{degf}]O)([nodesep=2.8, angle=\arabic{degf}]O)
        \pnode([nodesep=3.3, angle=\arabic{degf}]O){F\idx}

    % deadlock arrows
    \psset{nodesep=3pt, arrows=->}
        \setcounter{prev}{ (\idx + 4) - ((4 + \idx) / 5)*5}
	% Locked (L) arrow
	% Waiting (W) arrow

The special coordinates mode is used (\SpecialCoor), which allows for defining placement by polar coordinates using a node (O in this case) as a reference. Additionally the calc package allows for counter commands that accept infix notation expressions instead of a simple value. (References:calc, pstricks)