Home > Uncategorized > Threading, barrier waits, and tricksy behaviors.

Threading, barrier waits, and tricksy behaviors.

December 15th, 2009 heckel Leave a comment Go to comments

I tracked down the issue that was causing agents to stop, and it comes down to synchronization. Essentially, an agent could come back around to its next iteration and attempt to resolve actions before all of its behaviors had run, since they are running in separate threads. I’ve tested this by doing the dumb thing: I fixed the number of threads at run-time (the code is set up to allow the creation of more threads on demand), and dropped a barrier wait into the worker threads, so that the threads essentially run in lock-step: all agent controllers run, then all behaviors run. There’s only one barrier, so it really just requires the agent controllers to run before the behaviors.

The barrier wait is not a good solution. I’ve come up with a few different possible fixes, but I think the most logical is to just assign behaviors in the same thread as the agent controller runs. There are potential balancing issues with this, but those exist at the moment anyway.

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.