[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Timing out LUA programs
- From: Sean Middleditch <elanthis@...>
- Date: 18 Jun 2002 14:29:35 -0400
On Tue, 2002-06-18 at 14:18, Tom Wrensch wrote:
> Sean,
>
> On 18 Jun 2002, Sean Middleditch wrote:
>
> > Again, with Lua's co-threads support, it should be very easy (I would
> > imagine - haven't look at internals in a while) to make a
> > pre-emptive-ish threading system. Simply do something akin to forced
> > yields, add in Lua mutex/semaphore data types, etc. The main engine
> > would look at all available threads, and run each for X amount of time
> > or for X byte-code operations, then return to calling C code. This way,
> > an application could launch Lua threads, and then have a
> > "lua_run_threads" call in the main update/event loop.
>
> This is what I'm working on with the "count the byte codes" idea. I'm
> trying to see how easy it is and how ugly the implementation will be.
> If it seems possible to easily implement a lightweight preemptive
> system this way, I'll report it to the list.
Ah. I have such a system in use on Scriptix. I'm also planning on
getting it to work with signal alarms, too, for time-based threading
(which can be more efficient - a single "operator" may be a call into a
C function, which could take up a significant amount of time).
>
> - Tom
>