lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Oct 29, 2013 at 3:10 PM, Bob Schiavo
<rs.robertoschiavo@gmail.com> wrote:
> Hello everybody
>
> I’m a beginner of Lua, and I was wondering, looking at the use of Lua in
> environment with and without operating system, the following questions:
>
>
>
> Usage of Lua with SO
>
> 1.       Is it possible to embed Lua into uCLinux, or some other RTOSs (i.e
> freeRTOS)?
>
> 2.       If yes, is Lua embeddable “as it is” (I don’t think so) or it needs
> a porting, and how the porting can be done (is there some document/user
> guide that describes how to do that for the two SO above)?
>
>
>
> Usage of Lua without SO
>
> a)      Looking at eLua, that is Lua for embedded application on different
> platforms and CPUs, if I well understood, I have a complete description of
> the microcontroller and its resources. Supposing that I need only the
> interpreter to execute some script Lua, without any description of the
> platform resources (I mean no platform/…/FwLib sources files):
>
> Do I have to configure the building toolchain for eLua to skip the FwLib
> modules, or could Lua (not eLua) be ported directly on the platform?
>
>
>
> b)      I try to explain in poor words what I’m evaluating, so I might not
> be so clear as I would be.
>
> Assuming to have a scheduler that executes sequentially a script Lua
> (appl_script) and some other C functions, totally independent by the
> execution of the lua script. Something like the following (just a logical
> representation of the scheduler):
>
> While(true)
>
> {
>
>                Execution of lua app_script();
>
>                Execution of C_function1();
>
>                …
>
>                Execution of C_functionN();
>
> }
>
> If the lua script itself has a while(true), the others functions will never
> be executed.
>
> Is there the possibility, in a such situation, to interrupt the execution of
> the lua script, passing the control to the other functions of the scheduler,
> and resume the script next time it will be executed from the point it left
> off?

You can port Lua directly. It needs a certain amount of libc to work,
but you can stub out some of it if you eg do not need all the standard
libraries (say you have no useful io and will use something else). You
do need memory allocation and so on. It does depend on what your
environment has.

For the second part, it sounds like you want a scheduler, but again
depending on your platform you might be able to use interrupts and
multiple stacks.

Which environment are you looking at?