tech-userlevel archive

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

Re: Lua as a scripting language in NetBSD


I'm computer science msc student and I'm working in Lua embedded in
Linux kernel (which I call Lunatik) under the guidance of professor
Roberto Ierusalimschy. We already have a functional port of Lua core
to Linux kernel, which allows us to run arbitrary Lua code inside the
kernel. We have also created a small example application for this,
that allows users to write cpufreq governors purely in Lua.

I don't know if you are conversant with Linux cpufreq mechanism, but
it basically controls the frequency of laptop-like CPUs. Through the
cpufreq it is possible to switch the CPU clock dynamically to save
battery with a tolerable loss of performance. Through cpufreq
governors written in Lua it is possible to users create them own
policies to manage the CPU frequency. Here are some examples of
governors written in Lua:

-- simplified version of cpufreq ondemand governor
function governor()
   cpu_load = getLoad()

   if ( cpu_load > 80 ) then

       target( tab_freq.getMax() )

   elseif ( cpu_load < 30 ) then

       target( tab_freq.getPrev() )

-- modified version of ondemand with temperature concerns
function governor()
   cpu_load = getLoad()
   cpu_temp = getTemp()

   if ( cpu_load > 80 and cpu_temp < 65 ) then

       target( tab_freq.getMax() )

   elseif ( cpu_load < 30 or cpu_temp > 75 ) then

       target( tab_freq.getPrev() )

Lunaitk is still only a concept proof and a lab to study extensible
operating systems, but we are currently writing a paper and working on
a first public release. I will be glad to share my experience with
Lunatik and join you to port Lua to NetBSD kernel too.

This is a nice application and imo it shows the power of Lua embedded in an OS. Please be aware, however, that we are currently in the process of discussing wheter we want to include Lua into NetBSD, this has not yet been decided, although we had quite some positive reactions to the idea.

Integration of Lua into the kernel is even a different story than adding Lua to the base system. We have to think in which form to do, what services to expose etc. etc. And then I think personally that Lunatik is a bit of a misnomer... ;)

Well, since you work at the heart of Lua and with one of ots inevntors, you can possible help us with a technical question: Number format. I am well aware that I can compile Lua for different number formats, which is good, since there is no floating point math in BSD kernels usually. But what about 64 Bit integers? Can Lua be built to support 64 bit integers as number format?

Thanks for your feedback,
Marc Balmer

Home | Main Index | Thread Index | Old Index