lua-users home
lua-l archive

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


Hi Bob,

for the b) case there are decent Lua coroutines around. You can resume/yield back from Lua function wrapped in coroutine. So you'll probably get not while(true) in Lua part, but rather while(coroutine.yield(your_value)) - at this point you pass to the C caller your values (like returning them) and wait for resume from C part. That's looks like ping-pong. C part resume coroutine, coroutine do something, and return values to C. The C part may resume coroutine passing false to it, indicating that Lua part should finish (and probably clean up resources properly). Try to read some coroutine tutorials and experiment with them to get it handy. Note that coroutines not intended specifically for interaction with C, they are standard Lua library and can be used when both the caller and coroutine are Lua code, or with Lua caller and C method coroutine-wrapped.


On Tue, Oct 29, 2013 at 5: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?