Idle thread considers fsm step prepared by Op-thread (Otherwise some state changes may get lost)
authorMartin Troxler <ch1010277@ch10pc446>
Mon, 22 Nov 2010 09:09:23 +0100
changeset 2000 c76c01572f00
parent 1999 5f1269a71588
child 2001 2e05246f3b00
Idle thread considers fsm step prepared by Op-thread (Otherwise some state changes may get lost)
master/master.c
--- a/master/master.c	Mon Nov 22 08:50:34 2010 +0100
+++ b/master/master.c	Mon Nov 22 09:09:23 2010 +0100
@@ -1273,24 +1273,25 @@
         ecrt_master_receive(master);
         up(&master->io_sem);
 
-        fsm_exec = 0;
-        // execute master & slave state machines
-        if (down_interruptible(&master->master_sem))
-            break;
-        fsm_exec = ec_fsm_master_exec(&master->fsm);
-        for (slave = master->slaves;
-                slave < master->slaves + master->slave_count;
-                slave++) {
-            ec_fsm_slave_exec(&slave->fsm);
-        }
-        up(&master->master_sem);
-
-        // queue and send
-        down(&master->io_sem);
-        if (fsm_exec) {
-            ec_master_queue_datagram(master, &master->fsm_datagram);
-        }
-        ec_master_inject_external_datagrams(master);
+        if (master->injection_seq_rt == master->injection_seq_fsm) {
+            fsm_exec = 0;
+            // execute master & slave state machines
+            if (down_interruptible(&master->master_sem))
+                break;
+            fsm_exec = ec_fsm_master_exec(&master->fsm);
+            for (slave = master->slaves;
+                    slave < master->slaves + master->slave_count;
+                    slave++) {
+                ec_fsm_slave_exec(&slave->fsm);
+            }
+            up(&master->master_sem);
+
+            // queue and send
+            down(&master->io_sem);
+            if (fsm_exec) {
+                master->injection_seq_rt++;
+            }
+        }
         ecrt_master_send(master);
         sent_bytes = master->main_device.tx_skb[
             master->main_device.tx_ring_index]->len;
@@ -1342,7 +1343,7 @@
             // execute master & slave state machines
             if (down_interruptible(&master->master_sem))
                 break;
-            fsm_exec += ec_fsm_master_exec(&master->fsm);
+            fsm_exec = ec_fsm_master_exec(&master->fsm);
             for (slave = master->slaves;
                     slave < master->slaves + master->slave_count;
                     slave++) {