I mean having 2 computers at the same time. Does the mod run them like REALLY at the same time or is it some illusion again?
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
How does the mod work?
Started by Piorjade, 04 December 2016 - 07:56 PMPosted 04 December 2016 - 08:56 PM
I already know that a computer doesn't have real multitasking and that using coroutines is just rapidly going through every of them when they yield but how does it work with the mod and the computers?
I mean having 2 computers at the same time. Does the mod run them like REALLY at the same time or is it some illusion again?
I mean having 2 computers at the same time. Does the mod run them like REALLY at the same time or is it some illusion again?
Posted 04 December 2016 - 09:12 PM
I think they all share the same vm, and that all computers have their own coroutine, which probably is one of the reasons the 'too long without yielding' error occurs, so that other coroutines/computers can be resumed even if one computer was to lock up. I've seen the question related to cc emulators, and if I recall correctly the game does the same. Could be wrong, so feel free to correct me ;)/>
Posted 04 December 2016 - 09:21 PM
That's indeed how ComputerCraft does it. On a "real" computer we've got multiple cores and preemptive multitasking, but for the purposes of the mod, so long as one system is actively running code, all of the others are in a yielding state and will stay there until the active one either yields or gets killed.
Posted 04 December 2016 - 09:34 PM
Thanks
Posted 04 December 2016 - 10:23 PM
But from Lua, it isn't possible to kill processes (How can a yielding coroutine work?), right?That's indeed how ComputerCraft does it. On a "real" computer we've got multiple cores and preemptive multitasking, but for the purposes of the mod, so long as one system is actively running code, all of the others are in a yielding state and will stay there until the active one either yields or gets killed.
Edited on 04 December 2016 - 09:24 PM
Posted 04 December 2016 - 11:03 PM
ComputerCraft is able to kill processes because it's not part of the lua it's executing and is in a preemptive multitasking environment (Java).
Posted 03 January 2017 - 12:44 AM
I think it's important for the event queue, that all computers don't work asynchron.ComputerCraft is able to kill processes because it's not part of the lua it's executing and is in a preemptive multitasking environment (Java).
If one computer works without yielding, the others would get events, which this one doesn't get.
Posted 03 January 2017 - 12:56 AM
On the contrary, that computer would get events, it simply would not be able to act on them, as it never asks for one. In fact, CCTweaks allows up to 4 computers to execute simultaneously with no issues (they are still forced to yield eventually though)
Posted 03 January 2017 - 11:02 PM
That's why i thought about it, but i meant a long task, not an endless one. Also asynchronous computer in a network, can occur fatal errors.On the contrary, that computer would get events, it simply would not be able to act on them, as it never asks for one. In fact, CCTweaks allows up to 4 computers to execute simultaneously with no issues (they are still forced to yield eventually though)