6
\$\begingroup\$

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?

\$\endgroup\$

2 Answers 2

10
\$\begingroup\$

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

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

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .