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() )
end
end
-- 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() )
end
end
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.