lua-users home
lua-l archive

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


On 22 June 2016 at 06:45, Coda Highland <chighland@gmail.com> wrote:
> On Tue, Jun 21, 2016 at 1:43 PM, Daurnimator <quae@daurnimator.com> wrote:
>> On 22 June 2016 at 06:40, Coda Highland <chighland@gmail.com> wrote:
>>> On Tue, Jun 21, 2016 at 1:37 PM, Gregg Reynolds <dev@mobileink.com> wrote:
>>>>
>>>> On Jun 21, 2016 3:31 PM, "Coda Highland" <chighland@gmail.com> wrote:
>>>>> The fun part is when you realize that before Windows 95, the entire
>>>>> Windows operating system was cooperatively multitasked, and apps were
>>>>> expected to yield quickly when awakened by the OS.
>>>>>
>>>> MS-DOS: the Original Embedded System.
>>>
>>> MS-DOS wasn't even cooperatively multitasked. It was TECHNICALLY
>>> preemptively multitasked, in that triggering a TSR through an
>>> interrupt routine could happen at effectively arbitrary times in
>>> program flow, but there was no timesharing and the TSR would have to
>>> clean itself up and return control to the original program on its own.
>>
>> You can do similar in lua; just set a debug hook that yields :)
>>
>
> You are an evil evil person and I don't want to debug your code. ;)

It's actually not that bad. If you yield back to a scheduler things
work out nicely.

Two issues came up in the way of a 'good' implementation last time I tried:

1. in lua (not luajit) debug hooks are per thread; this is great from
being able to make sure only a single thread yields; but troublesome
in that you end up needing to wrap coroutine.create/coroutine.wrap to
track coroutine creation (and there's no way to find out if people are
creating threads using the C api).
I did mention this to Roberto at last year's workshop.

2. yielding from a debug hook discards the values yielded.
See http://lua-users.org/lists/lua-l/2015-12/msg00111.html