To avoid conflict and deadlock states in waterway with multiple locks and canals, a computer based traffic management system with proper control policy must be applied. The paper proposes a formal method for design of deadlock prevention supervisor by using discrete event theory, multiple reentrant flowlines class of Petri net and P-invariants control places calculation. By using and/or matrix algebra, authors analyze the structural characteristics of Petri net in order to find first and second level deadlocks. First level deadlocks are prevented by maintaining the number of vessels in the critical subsystems below the number of vessels in the critical circuits. A method for second level deadlock prevention, which is based on P-invariants, ensures that the key resources would not be the last available resources in the system. Functionality of the supervisor is verified by a computer simulation using Matlab software with Petri net toolbox and P-timed Petri net model of waterway.