In my experience, two approaches are preferred when people want to handle scripting in multithreaded environment.

  1. Synchronize every accesses to scripting module with one coarse-grained lock.
  2. No Synchronization - Scripting module should be used by just one logic thread.

Of course, both solutions are not scalable in multi-core perspective.

Question - Is there any other (multi-core) scalable solution?


Treat scripts like the GPU treats shaders- no global variables, limited inputs and outputs, that is, enforce thread safety via language rules.

  • \$\begingroup\$ Ah, side-effectless approach. It would be a good solution for some situation. Thanks for your answer! \$\endgroup\$ – summerlight Jan 23 '11 at 11:08

It's impossible to say what sort of synchronisation you need when you've not mentioned the kind of resources you will have your scripts accessing.

Personally, having looked at what happens in a couple of game engines and thought about the various implications of scripting with regards to concurrency, I'd be inclined to have all game logic and scripting running sequentially and have other features use your extra cores.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.