A MOVIE thread is an active entity, which code is being interpreted by the MovieScript interpreter.
|
Each thread contains its descriptor, and three stacks:
-
Operand Stack -- used to store operands in the postfix notation
-
Execution Stack -- utilized internally by the interpreter
-
Dictionary Stack -- containing dictionaries which hold {name,object} pairs.
|
During a context switch, instead of swapping contents of registers, the pointers to those three stacks are being swapped. After that, the interpreter starts interpreting the new thread.
|
When a new task is being started, there is automatically created a thread within it. All other threads have to be explicitly created by the fork operator. That operator copies the content of its stacks onto the new thread's stacks. This allows new threads to inherit parent`s context (alike global variables in TCE). All subsequent operations on stacks are not visible to both the parent and the child (likewise local variables in TCE).
|