There are many different types of charts and diagrams we use to formalize scenarios and study them tangibly -- activity diagrams, sequence diagrams, etc.

I've been faced with a pretty complex locking scenario and I'd like to try and bring all the information together into one diagram so I can explain it (to others and to myself). I imagine it would be similar to a sequence diagram, but I can't formalize the thought. Is there such a mental tool and, if so, how can I use it?

  • Sounds like a random whiteboard drawing could work here, I am not sure you need UML or another formal documentation type.
    – user22815
    Oct 19, 2015 at 19:26
  • 2
    Yes, a sequence diagram seems to be the right choice. If there are many different use cases, perhaps you might need to make many sequence diagrams.
    – rwong
    Oct 19, 2015 at 20:04
  • @Snowman I guess I'm just not sure how I would represent a given scenario. I had an idea, but it seems overly complex: for each component (i.e. column) of the sequence diagram, have lines running down for each possible lock it can hold. When information moves between components, it will physically run up against the lock. This doesn't account for different locks for different data, though -- and doesn't account for contrived locking (where everyone must attempt to lock the data before setting it -- what we have). Oct 19, 2015 at 20:14

2 Answers 2


Petri net formalism combines both graphical representation and mathematical definition. This includes for instance ability to prove deadlock existence.

Quoting Wikipedia:

A Petri net consists of places, transitions, and arcs. Arcs run from a place to a transition or vice versa, never between places or between transitions. The places from which an arc runs to a transition are called the input places of the transition; the places to which arcs run from a transition are called the output places of the transition.

Graphically, places in a Petri net may contain a discrete number of marks called tokens. Any distribution of tokens over the places will represent a configuration of the net called a marking. In an abstract sense relating to a Petri net diagram, a transition of a Petri net may fire if it is enabled, i.e. there are sufficient tokens in all of its input places; when the transition fires, it consumes the required input tokens, and creates tokens in its output places. A firing is atomic, i.e. a single non-interruptible step.

Unless an execution policy (e.g. a strict ordering of transitions, describing precedence) is defined, the execution of Petri nets is nondeterministic: when multiple transitions are enabled at the same time, they will fire in any order.

Since firing is nondeterministic, and multiple tokens may be present anywhere in the net (even in the same place), Petri nets are well suited for modeling the concurrent behavior of distributed systems.

Petri net example


This is a multi-dimensional graph

I would anticipate that lock analysis on a larger number of elements increases complexity exponentially (or according to a factorial function). Therefore, to minimise complexity you would need to find a methodology that discovers mostly-isolated locking groups to exclude their internal interactions from the broader context.

While Locks are State machines, the state transitions themselves are not important, but rather the interconnectivity and therefore the discovery of potential deadlocks or races is more important.

I believe that in complex (multi-dimensional graph) situations that elude in-the-mind visualisation, it's best to list individual "facts" in one big list first (as you think of them), then try to expand (find missing elements), then cluster, then diagram. This is important, because the working-set memory in your brain is not large enough beyond Nx elements.

Therefore, you should:

  • list out all lock resources (a dot-pointed list not a diagram)
  • create sub-points for each lock of the resource users and the type of use (read/write)
  • create "fragments" of the whole picture (it's unlikely that you can fit everything on a large diagram, because 2D is not enough - you will have too many overlapping lines)
  • if you do try to create a full diagram, permit the same "lock users" to appear multiple times, but not the locks themselves. Maybe put an asterisk on any "lock users" that you have added multiple times in the diagram.

I would draw lock-resources as circles, and lock-users as rectangles. I would keep the diagrams as simple as possible, and write the details as dot-points or paragraphs underneath diagrams in a document (eg. Google Docs).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.