question

Cameron Pluim avatar image
3 Likes"
Cameron Pluim asked Brandon Peterson answered

Preemption not releasing all tokens correctly

In the attached model, process flow is creating 2 teams of tokens, and adding them to a teams list. Team 1 has an initialization delay because I want to make sure team 2 finishes it's initialization first.

I also have a time table in which I want to put all my teams on break at the same time, so there is an event triggered source which fires on the down function of my time table. This token will pull all the tokens from the teams list, and preempt them, pulling them away from their current task.

Without the initialization delay for Team 1, all tokens are pulled and preempted correctly, but with the initialization delay, preemption releases all of the tokens it pulls except for the last one, which gets left to work all by himself :(.

I've found that I can fix the problem if I add a delay of 0 after the Pull and before the Save Context,

but I wouldn't think that this should be necessary.

bugwithpreemption.fsm

FlexSim 16.2.0
time tablereleaseprocess flow preemption
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Brandon Peterson avatar image
1 Like"
Brandon Peterson answered

Cameron,

I looked at your model and your assumption of adding a zero delay is correct. When the last token enters the delay it does not finish executing the code in the delay before the breaktime token executes the "release token" activity block. You can see this if you can click on the token left behind just after the other three are moved (if you are stepping through the run). The token will not have an "Exit Time" value assigned yet.

So, it would appear that the delay activity is firing as two distinct parts in zero time. This should make sense as it is often used with a zero time to let other code/activities fire/execute before the token that entered the delay is allowed to move on. Coincidentally, this is exactly what you would need to add the one to the breaktime flow for! Thus the necessity of your solution is to allow for the possibility of the exact same solution to exist.

Welcome to the club! For those of us who find the solution to many of our problems is the problem!

All fun aside, I hope this answers your question and that all is going well for you!

Brandon

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.