lua-users home
lua-l archive

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



Yes, Bert's situation sounds challenging (maybe to the degree of foolishness? :) to say the least.

I would consider doing an "event dispatch" interrupt handler (in C) that would sit in the other end of a FIFO queue, the other end being polled by Lua (can you run one instance, as the main loop?) to take in "commands". Of course, those commands can be full Lua scriptlets, nothing's preventing that. But the point would be, you end up having them in the queue, so getting multiple interrupts won't be an issue (unless the queue grows and grows and... then you have too slow a CPU anyways ;)

Hope this helps, still thinking you'll never fit Lua in 30kB binary. :P Please prove me wrong.

-asko


David Brown kirjoitti 15.5.2006 kello 14.19:

Hi Bert,

I haven't done much with Lua yet, but I've plenty of experience with
embedded systems. Calling an interpreted language from an interrupt running at that speed sounds like a bad idea. 30 kHz is pretty fast - even for an ARM. Depending on the type of ARM and its clock speed, you have something like 1000 to 10000 clock cycles between interrupts. That's not a lot when you are running an interpreter. At best, you will use a large proportion of
your cpu time, and will get very large jitter.  In particular, garbage
collection may cause occasional extra delays.

If you really need to run lua scripts triggered by interrupts, you are
probably better off setting a flag in the interrupt routine, and using that
to start the script from within your main loop.

mvh.,

David



----- Original Message -----
From: bert
To: Lua list
Sent: Monday, May 15, 2006 9:05 AM
Subject: Re: lua on ARM7


Hi All,

thanks a lot for the helpful replies. I tried compiling LUA and it is true that I end up at over 30K but less than 64K of code. that is compiling in thumb mode so I suspect that it will be even more if I try ARM mode. I have
tried with the IAR EW compiler, still have to try the GCC.

Now, the firmware would be running LUA code in an interrupt. How would this be done to keep things thread-safe (nested interrupts?), and is it realistic to call a LUA function from an interrupt routine being called at 30kHz?

It somehow makes more sense to me to compile the LUA code on my host PC to something that can be run very efficiently on the ARM platform, like native
code, but then I'm not sure how difficult it is to compile LUA code to
native ARM directly.

Thanks,
Bert


Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
What parts of the LUA source code do I need for making
this work and what can I safely remove?
This is for Lua 4.0, but may get you started:

http://www.lua.org/notes/ltn002.html

Yes, and Lua 5.x this is even easier. See etc/noparser.c
This will save you some 30% of the core code.
--lhf





Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2¢/min
with Yahoo! Messenger with Voice.