Multithreading in Lua

Posted by RCIX on Stack Overflow See other posts from Stack Overflow or by RCIX
Published on 2010-06-04T22:09:22Z Indexed on 2010/06/05 14:22 UTC
Read the original article Hit count: 345

I was having a discussion with my friend the other day. I was saying how that, in pure Lua, you couldn't build a preemptive multitasking system. He claims you can, because of the following reason:

Both C and Lua have no inbuilt threading libraries [OP's note: well, Lua technically does, but AFAIK it's not useful for our purposes]. Windows, which is written in mostly C(++) has pre-emptive multitasking, which they built from scratch. Therefore, you should be able to do the same in Lua. The big problem i see with that is that the main way preemptive multitasking works (to my knowledge) is that it generates regular interrupts which the manager uses to get control and determine what code it should be working on next. I also don't think Lua has any facility that can do that.

My question is: is it possible to write a pure-Lua library that allows people to have pre-emptive multitasking?

© Stack Overflow or respective owner

Related posts about multithreading

Related posts about lua