Closed mbonani closed 4 years ago
The vm will never exit the loop, so it will never process any incomming event or anything else. The vm could put a limit on the number of instructions that can be run and abort when we go over.
As written the above code can never be supported, it's an infinite loop
The original design was that infinite (or taking too long) loops will be killed if there are incoming events (either internal or from the network). If my memory is correct, the idea was to allocate 1k instructions upon an event that will surely be executed, but exceeding this number there is no guarantee (the 1k number is arbitrary of course, but it did sound reasonable for a small robot like Thymio). The behaviour of the simulator should be consistent with this design. I think that at some point the Thymio also followed that, but I am not totally sure we might have missed it all along (which seems strange, as for the paper for sure we had this behaviour, but the paper was probably not using the Thymio but the development board, although I do not see why there would be a difference in behaviour at that level between the two).
Reading at the code more carefully, it doesn't seem much is missing
https://github.com/Mobsya/aseba/blob/5b32558e4bd3cc7e58075bce548c1e7636308ac4/aseba/vm/vm.c#L532
PR https://github.com/Mobsya/aseba/pull/666 Thymio has a 1000 steps limit - that seems low, do we increase it @mbonani?
I will make some test, probably it is not so low.
clearly 1000 step are not sufficient: a simple code that should work
var buff[500]
var i
var j
onevent button.forward
for i in 0:499 do
buff[i]=i
end
it is working with 10000 limit but no more with the following code
var buff[500]
var i
var j
onevent button.forward
for j in 0:1 do
for i in 0:499 do
buff[i]=i
end
end
with 0xFFFF (Max)
j
can go up to 10
and it makes go out from an infinite loop in less of 1 sec that's for me reasonable
That was my gut feeling - do you want me to make a pr or will you ?
On Fri, Oct 11, 2019 at 1:22 PM Michael Bonani notifications@github.com wrote:
clearly 1000 step are not sufficient: a simple code that should work
var buff[500] var i var j
onevent button.forward for i in 0:499 do buff[i]=i end
it is working with 10000 limit but no more with the following code
var buff[500] var i var j
onevent button.forward for j in 0:1 do for i in 0:499 do buff[i]=i end end
with 0xFFFF (Max) j can go up to 10 and it makes go out from an infinite loop in less of 1 sec that's for me reasonable
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Mobsya/aseba-target-thymio2/issues/51?email_source=notifications&email_token=AAKX76YHOMA5M7GI3AW5SWDQOBOXTA5CNFSM4IYWW2U2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEA7V77I#issuecomment-541024253, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKX7644E4NRFRQILV346KDQOBOXTANCNFSM4IYWW2UQ .
I will do
Just a note, as long as there is no incoming event, the current one is not killed. But I see the rationale of increasing the minimum number of instructions executed. According to the Aseba paper (p. 8), the VM executes 600k instructions per second. So if you put 30k as the minimal amount, it should have a delay of no more than 50ms in average. Note that you can also put an initial large amount, to make sure to execute at least these number of instructions, and then use a smaller amount, so that there is more reactivity. This requires a bit more complex glue code though.
fix in v14
actually it seems that a blcoking event whit a while loop is not killed and block all the VM.
it is refered also here: https://github.com/Mobsya/aseba/issues/653