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. Michel -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michel Gouget Sent: mardi 2 octobre 2007 00:26 To: 'EMC developers' Subject: Re: [Emc-developers] Multiple UI synchro: Big problem! Thanks, Alex, for the help and the pointers; >From http://www.isd.mel.nist.gov/projects/rcslib/nml-tutorial.pdf , slide 70: A graphic user interface (GUI) has been added. Now, the command buffer has two writers, and the status buffer has two readers. NML ensures mutual exclusion, as before. Note that multiple writers need to coordinate their writing to avoid overwrites. Multiple readers of queued NML buffers need to coordinate their reading, to avoid stolen messages. So I have to sync emcsh... Michel -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michel Gouget Sent: lundi 1 octobre 2007 21:22 To: [email protected] Subject: [Emc-developers] Multiple UI synchro: Big problem! Hello ! I am still developing my Druids. I have now a working one which sends a correct program to EMC as a sequence of MDI commands. My problem is to send these MDI commands while the EMC UI (and more specifically the mini) is running. I understood that there is an NML library, which allows the UI to send commands to EMC, and receive responses. This is done by sending a command with a serial_number, waiting for an acknowledge with the same serial_number, then waiting again for a DONE, still with the same serial_number. The problem comes when the druid sends commands. *sometime* an ACK or A DONE never comes, and instead I get another serial_number. I wrote a test program and a makefile available here: http://www.gouget.org/emc/ I dont see how I can solve this problem; HELP!!! Michel ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Emc-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-developers ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Emc-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-developers ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Emc-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-developers
