MUTEX in MQL5. Is it possible? - page 2

 
sys4:

One question,  If 1 EA runs on 1 thread, then it seems onTimer won't be called while onTick has some blocking function call or sleep more than timer interval??

Why don't MT5 separating timer event thread? because of Mutex implementation?

This is question for Metaquotes, you can ask them on the ServiceDesk.

For now, 1 thread by EA, you have to deal with.

 

I want to know if I need lock a file while writing...

If it's writing half way, then another EA of mine come to read data...only get a half?

Should I worry about that ? or the file lock is set default in MQL ?


Many Thanks.

 
Weixing Meng:

I want to know if I need lock a file while writing...

If it's writing half way, then another EA of mine come to read data...only get a half?

Should I worry about that ? or the file lock is set default in MQL ?


Many Thanks.

This totally depends on how you are using the files!

If you open a file you can determine whether the access is shared or not - see FileOpen() in the Reference of the Editor (F1)

 
sys4: Why don't MT5 separating timer event thread? because of Mutex implementation?

Because that's how they made it. We can't read their minds. Ask them, not us users.

 
humbertobrandao Brandao: Because to implement a mutex, I need to call a special function that runs a System Call on OS. But I don't know if this function exists in MQL5.
  1. By definition system calls not not part of MQL5.
  2. Metaquotes gave you the necessary call.
    Function provides atomic access to the global variable, so it can be used for providing of a mutex at interaction of several Expert Advisors working simultaneously within one client terminal.
              Global Variables of the Terminal / GlobalVariableSetOnCondition - Reference on algorithmic/automated trading language for MetaTrader 5
Files:
mutex.mqh  4 kb
 
Hi,

this question is old, so maybe some changes were made from then to now. So I'ld like confirmation:

1) Does any EA still runs in the same thread, including OnTimer events?
2) Do I still need to implement a mutex system to access Global Variables of the Terminal?

I have the impression once I read about a recent version of MT5/MQL5 including some native mutexes, so external libraries (such as https://www.mql5.com/pt/code/1835) are no longer necessary. Am I right?
Mutex - WinAPI
Mutex - WinAPI
  • www.mql5.com
Sincroniza processos ОС/EA/MT etc. Não são mais necessários DLLs agora.
 
Martin Bittencourt:
Hi,

this question is old, so maybe some changes were made from then to now. So I'ld like confirmation:

1) Does any EA still runs in the same thread, including OnTimer events?
2) Do I still need to implement a mutex system to access Global Variables of the Terminal?

I have the impression once I read about a recent version of MT5/MQL5 including some native mutexes, so external libraries (such as https://www.mql5.com/pt/code/1835) are no longer necessary. Am I right?
Nothing has changed. You may need a mutex when accessing GVT.
Reason: