Skip to main content.

Wednesday, August 15, 2007

Last night I thought about making coroutine model a bit more complete.

The most urgent thing we need is a timed wait on semaphores. Actually, all that's needed should be here, it should be just a matter of putting down the interface and possibly to review the work model of the Wait and Sleep requests for the VM.

Another thing we may want is coroutine stop. It may be an automatic kind request i.e. a check on every sleep or semaphore wait routine. To implement it seriously, we should provide hooks for RTL and module functions blocking the VM, as file reads, and that may be a bit tricky ATM. It may also be a rough interruption; we have track of allocated resources, and ATM we don't have coroutine mutexes. However, this may rise a problem in VM preempt-and-calls. A coroutine may be preempted, a callback may be called and that callback may stop the coroutine, destroying the context on which both the preempted coroutine and the stopping callbacks are running... that would lead to nice crashes.

Moreover, ATM we don't have a "coroutine handler". The launch statement doesn't return a coroutine handler. I thought we may easily create a VM object called Coroutine, with a start() ad a stop() method, and also some support for things as wait/notify synchronization models.

We may also be interested to mutexes, but at that point we'd start entering the multithreading field, and other problem arise, so I would limit to those two things now.

Doing them carefully, and also with a minimal refitting of the context management, the thing should be ready in two days, but by now I don't have time nor "release space" to do it. I want tsubame to fly for a while, and coroutine flexibility is a secondary matter for now; so we'll do all this later, around 0.9

Comments

No comments yet

Add Comment

This item is closed, it's not possible to add new comments to it or to vote on it