Euphoria dlls with multitasking

new topic     » topic index » view thread      » older message » newer message

Forked from Re: submitting code

jaygade said...

I actually find it interesting since I couldn't find the referenced discussions on the dev list.

The background for this issue is that trying to use any of the multitasking API in euphoria code translated into a dll results in a compile error. Jeremy had wondered if there were an easy way to make this work. The main reason why it doesn't is the design of multitasking. In fact, there are two designs.

First, there is one way of dealing with tasks in interpreted code. In many ways, this is a lot easier to handle, since the backend of euphoria handles all of the call stack, etc. With translated code, of course, we're using the standard stack space supplied by the OS. Currently, these two systems operate completely separately.

We actually have an open issue (though low priority) regarding this as it affects the front end of the interpreter. The front end sort of cheats, in that it's translated code, but it uses the standard interpreted backend for its runtime code, as opposed to the normal translated backend that the translator links to your translated euphoria code. In most cases, it doesn't really make a difference, since sprintf() is sprintf() is sprintf(). However, as noted above, the implementation of tasking is not so simple, and is switched out via ifdefs in the C code (see be_task.c).

So, in order to be able to integrate a dll with interpreted euphoria code, we need a way for the two implementations to coexist and work together. Of course, it might be a translated application that's using the euphoria dll, but that's a little easier, since we'd only be using a single tasking mode.

Of course, there's some additional administrative stuff that would have to happen to be able to do this. When you loaded a euphoria dll, there'd need to be some sort of initialization/handshake that happened in order to let the dll know where to call task_yield(), or whatever.

There are probably other implementation issues that we'd encounter implementing this, but we've already found that we probably need to rewrite the translated tasking system anyways. Translated tasks fail on recent linuxes. I think it's trying to prevent against things like stack smashing attacks, which I think is what a translated task looks like to the kernel.

There are lots of reasons why this is desirable. Let's start with one of the initial reasons for translating euphoria code into a dll: making your code run faster. Suppose you did this with the standard library. It's presumed to be well tested, etc, so it might be a good candidate for speeding up your code. There are a few places where multitasking is used (or can be used) to improve performance. One such place is within http.e.

In the future, there are some plans to integrate translated and interpreted code so that it might even be transparent to the programmer. Excluding that code from using tasks could make the feature a lot less useful.

Matt

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu