Schematex
petri·Murata 1989 / ISO-IEC 15909-1 (place/transition net)·software, industrial·complexity 2/3·since v0.6.0

Semaphore mutual exclusion with a firing sequence

Two processes share one semaphore token, laid out left to right; a firing sequence is played from the initial marking so the diagram shows the resulting state and which transition is enabled next.

For the concurrency engineer

Open in Playground →
schematex§ source-defined
Petri net — Semaphore Mutual Exclusion 5 places, 4 transitions, 12 arcs. Marking {ReadyA:1, CriticalB:1}. Enabled: ExitB. Semaphore Mutual Exclusion Semaphore ReadyA ReadyB CriticalA CriticalB EnterA ExitA EnterB ExitB
25 lines · 596 chars
✓ parsed·0.0 ms·0 B
100%

Scenario

Processes A and B each cycle Ready → Enter → Critical → Exit and back. A single Semaphore token is shared between them, so only one process can be in its critical section at a time. The net also replays a short run — A enters and leaves, then B enters — so you see the state after those three steps instead of the starting state.

Annotation key

How to read

The two process cycles mirror each other, with the Semaphore between them feeding both Enter transitions and refilled by both Exit transitions. After the firing sequence, A is back in ReadyA, B holds its token in CriticalB, and the Semaphore is empty. So EnterA cannot fire — it needs the semaphore token — and the only enabled transition is ExitB. No marking ever puts tokens in CriticalA and CriticalB together; that is the mutual-exclusion guarantee.

Petri net syntax