|
|
||
|
|
Guys, IMHO a non-preemptible thread and a coroutine (at least the kind of coroutines you are talking about, which have a private stack) are the same thing. When such a thread yields, it saves (usually in its stack) the context it needs for resuming. The stack pointer must be saved somewhere else. The context depends on the language implementation; in a typical compiled language it may include some machine registers if they hold variables. This is the same context that any standard function must save when calling another function. In the case of a preemptible thread, control may be taken away from the thread as the result of an interrupt. This context switching works the same as a yield (save context in current stack -> switch stack -> recover context from new stack), but the context is bigger, since it is the context saved by an interrupt, and by definition an interrupt must save and restore everything necessary in order to leave no trace of its execution. The context saved by an interrupt usually includes all machine registers and maybe other stuff like some IO device registers, memory mapping, segment tables, etc. etc. The exact contents depend basically on the hardware and the OS, not the language implementation, and it is a superset of what a thread must save and restore when yielding. Am I missing something? Hugo Etchegoyen David Kastrup escribió: Adrien de Croy <adrien@qbik.com> writes: --
Ing.
Hugo Eduardo Etchegoyen Compañía
Hasar | Grupo
Hasar |