Re: Multiple UI synchro: Big problem!
Michel Gouget <
michel@...>
2007-10-02 20:28:05 GMT
I have now a working solution for running multiple UIs at the same time,
which involves using a semaphore, and modifying emcsh.c.
I found that the NML communication in EMC is rather rustic, with absolutely
no synchronization. It is based on buffers which are transmitted on demand.
When 2 processes ask for the same buffer at the same time, the result is
non-deterministic :(. The UIs sample the status buffer, and act accordingly.
As they need to be responsive, the UIs usually don't even wait for command
completion.
All the interaction between the UIs and emc is done through emcsh.cc. So I
modified it to control the access by using a semaphore. When the druid wants
to access emc, it grabs the semaphore, blocking if necessary.
I tried 2 strategies for the UI (source is in http://www.gouget.org/emc ):
- emcsh2.cc : try to grab the semaphore (non blocking), if it fails, don't
perform the op, but return OK.
- emcsh3.cc: grab the semaphore, blocking if needed.
The emc2.cc strategy works surprisingly well, but I don't like it as it is
not very clean....
The emc3.cc strategy works well, but the UI becomes sluggish when the druid
sends mdi commands.
The latest version of the druid (http://www.gouget.org/druids) manages the
semaphore. In order to use it, replace your emcsh.cc with emcsh3.cc, and
recompile emc.
If we want druids support in EMC, we will need to incorporate emc3.cc, or
something similar, in the EMC code; I don't see any other solution.
(Continue reading)