[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re : luachip
- From: David Given <dg@...>
- Date: Wed, 11 Aug 2004 11:09:10 +0100
On Wednesday 11 August 2004 02:47, Joshua Jensen wrote:
[...]
> Or, alternatively, you can look at LuaRC, a reference counted version of
> Lua 5.02. It works great in real-time applications, as no garbage
> collection blips happen (that is, you are limited by the underlying
> realloc() implementation, and that's replaceable with higher performance
> versions).
The problem with reference counting is that when an object gets dereferenced
you can spend an unbounded amount of time freeing it (because it will have
references to other objects, which will have references to other objects,
etc). Which still makes it unsuitable for real time, I'm afraid.
Although with any GC system you can calculate the maximum amount of time any
garbage collection can take; work out the most complex object tree you can
fit into your memory, and your GC system can't take any more time than that
to run. This now becomes your realtime latency limit. For systems as powerful
as the one envisaged this will be quite small in human terms; probably on the
order of tenths of a second. However, this is still vast in computer terms
and you'd have to be careful what you did.
Example code:
function main()
while true
local a = readport(1)
writeport(2, a)
end
end
How long does it take between loops? Hey, look, there's a local variable.
It'll run quickly until memory fills up... and then stop, and garbage
collect, and then run again. If port1 didn't have a FIFO and got a new
reading ever 50 milliseconds and the runtime took 100 milliseconds to do the
GC, you're stuffed.
(Yes, I know locals don't work like that in practice, but you'll run into this
everywhere.)
--
+- David Given --McQ-+ "Working with Unix is like wrestling a worthy
| dg@cowlark.com | opponent. Working with Windows is like attacking a
| (dg@tao-group.com) | small whining child who is carrying a .38." ---
+- www.cowlark.com --+ Nancy Lebovitz