Is Access to Global Variables Thread-Safe?

 

Hello,

 

Terminal global variables are available for concurrent access from all running EAs. Each EA runs on its own thread (as stated on official documentation).

Is access (Read/Write) to global variables assured to be race-condition-free?

 

More Generally: Can the MT4 terminal start processing a tick of symbol B, while a previous tick of symbol A is being processed?

 

Thanks much. 

 
Simha:
Is access (Read/Write) to global variables assured to be race-condition-free?
More Generally: Can the MT4 terminal start processing a tick of symbol B, while a previous tick of symbol A is being processed?
  1. Only OnCondition could be, which I used it to write a mutex.
  2. Yes. That is exactly what "Each EA runs on its own thread" means.
 

The GlobalVariables have a time stamp of the last access: GlobalVariableTime("name") which seems to be the local (pc) time (not TimeCurrent()) and is accurate to the nearest second.





 
WHRoeder:
  1. Only OnCondition could be, which I used it to write a mutex.
  2. Yes. That is exactly what "Each EA runs on its own thread" means.

Thanks for the useful answer.

 
gooly:

The GlobalVariables have a time stamp of the last access: GlobalVariableTime("name") which seems to be the local (pc) time (not TimeCurrent()) and is accurate to the nearest second. 

Thanks. I've found this useful.

Reason: