Jump to content




How does the mod work?


  • You cannot reply to this topic
8 replies to this topic

#1 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 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?

#2 supernicejohn

  • Members
  • 98 posts
  • LocationSweden

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 ;)

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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.

#4 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 04 December 2016 - 09:34 PM

Thanks

#5 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 04 December 2016 - 10:23 PM

View PostBomb Bloke, on 04 December 2016 - 09:21 PM, said:

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.
But from Lua, it isn't possible to kill processes (How can a yielding coroutine work?), right?

Edited by Sewbacca, 04 December 2016 - 10:24 PM.


#6 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

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).

#7 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 03 January 2017 - 12:44 AM

View PostKingofGamesYami, on 04 December 2016 - 11:03 PM, said:

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).
I think it's important for the event queue, that all computers don't work asynchron.
If one computer works without yielding, the others would get events, which this one doesn't get.

#8 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

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)

#9 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 03 January 2017 - 11:02 PM

View PostKingofGamesYami, on 03 January 2017 - 12:56 AM, said:

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)
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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users