How can I prevent a deadlock state in a SimEvents model using SimEvents R2013b?

1 view (last 30 days)
Two entities are being submitted to two servers, i.e. one entity per server. If server #1 is occupied, it should pause (and block) server #2 until server #1 becomes unoccupied. The same operation occurs if server #2 becomes occupied. At no point in time should both servers be blocked. However, an issue arises if the servers receive the entities at the "same" time, both servers become blocked and thus the system becomes locked. 
The attached model, "simpleExample_eventPrior.slx", demonstrates this behavior.
How can I prevent a deadlock state in a SimEvents model?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Jul 2014
A method that will provide control to select which block has priority in this case would be to use a MATLAB Function block to break this "deadlock" state. Effectively when both the 'so' outputs from N-Server and N-Server1 are equally 1, preference should be given to one server. The attached example, "simpleExample_eventPrior_TS.slx", demonstrates a possible method to resolve this "deadlock" state.  
Additionally, since these blocks are mutually driving each other, priorities for the ServiceCompletion and the ControlEvent states are executed at different times. For additional information on the priorities and execution order, the SimEvents engine looks to be performing the ServiceCompletion for both N-Servers first in order of their priorities. Then afterwards, when both servers are full, the ControlRequests are evaluated. To further inspect the order of a SimEvents simulation, you can enter debug mode. This can be performed via the following command in the MATLAB command line:
 
>> sedebug('simpleExample_eventPrior')
 
Once in the debugger, the "runtoend" command can be used to generate a log for this particular example. At the end of the log, you can see that the ControlRequests for the servers are evaluated after both servers are already full. Hence, this model will alway end in the deadlock state.

More Answers (0)

Categories

Find more on Discrete-Event Simulation in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2013b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!