Browse Source

Only break while after 20 iterations, to keep overhead lower

Yentl Van Tendeloo 7 years ago
parent
commit
605a7a15c0

+ 1 - 1
hybrid_server/classes/mvkcontroller.xml

@@ -321,7 +321,7 @@
                             </script>
                             </script>
                             <raise scope="broad" event="resume_task"/>
                             <raise scope="broad" event="resume_task"/>
                         </onentry>
                         </onentry>
-                        <transition after="self.sccd_yield() + 100" target="."/>
+                        <transition after="self.sccd_yield() + 600" target="."/>
                     </state>
                     </state>
                 </state>
                 </state>
             </parallel>
             </parallel>

+ 7 - 2
kernel/modelverse_kernel/main.py

@@ -351,15 +351,20 @@ class ModelverseKernel(object):
                                 ("RD", [inst, "body"])]
                                 ("RD", [inst, "body"])]
             (prev_cond, instruction_cond), = yield [("CALL_ARGS", [self.print_instruction, (cond, 0, indent+1)])]
             (prev_cond, instruction_cond), = yield [("CALL_ARGS", [self.print_instruction, (cond, 0, indent+1)])]
             (prev_body, instruction_body), = yield [("CALL_ARGS", [self.print_instruction, (body, indent+1)])]
             (prev_body, instruction_body), = yield [("CALL_ARGS", [self.print_instruction, (body, indent+1)])]
-            instruction = "  " * indent + "while 1:\n" + prev_cond + \
+            instruction = "  " * indent + "__counter_%s = 0\n" % inst + \
+                          "  " * indent + "while 1:\n" + prev_cond + \
                           "  " * (indent + 1) + "if 'value' not in %s:\n" % instruction_cond + \
                           "  " * (indent + 1) + "if 'value' not in %s:\n" % instruction_cond + \
                           "  " * (indent + 2) + "%s['value'], = yield [('RV', [%s['id']])]\n" % (instruction_cond, instruction_cond) + \
                           "  " * (indent + 2) + "%s['value'], = yield [('RV', [%s['id']])]\n" % (instruction_cond, instruction_cond) + \
                           "  " * (indent + 1) + "if not (%s['value']):\n" % instruction_cond + \
                           "  " * (indent + 1) + "if not (%s['value']):\n" % instruction_cond + \
                           "  " * (indent + 2) + "break\n" + \
                           "  " * (indent + 2) + "break\n" + \
                           "  " * (indent + 1) + "else:\n" + \
                           "  " * (indent + 1) + "else:\n" + \
-                          "  " * (indent + 2) + "yield None\n" + \
+                          "  " * (indent + 2) + "__counter_%s += 1\n" % inst + \
+                          "  " * (indent + 2) + "if __counter_%s > 20:\n" % inst + \
+                          "  " * (indent + 3) + "yield None\n" + \
+                          "  " * (indent + 3) + "__counter_%s = 0\n" % inst + \
                           prev_body + instruction_body
                           prev_body + instruction_body
 
 
+
         next_inst, = yield [("RD", [inst, "next"])]
         next_inst, = yield [("RD", [inst, "next"])]
         if next_inst:
         if next_inst:
             (prev_next, inst_next), = yield [("CALL_ARGS", [self.print_instruction, (next_inst, indent)])]
             (prev_next, inst_next), = yield [("CALL_ARGS", [self.print_instruction, (next_inst, indent)])]

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
 
-Date:   Wed May 23 09:21:50 2018
+Date:   Wed May 23 09:41:55 2018
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server