Hi all, since nearly three years PicoLisp supports coroutines (64-bit version). Now suddenly it occurred to me that the way I implemented them might be illegal.
The problem is how individual stacks for the coroutines are allocated. I do this by reserving space on the stack (by decrementing the stack pointer) upon starting a new coroutine. Execution of that coroutine may be suspended (with 'yield', so that execution continues in the main program or some other coroutine), to be resumed later. Switching between individual (co)routines is done by moving the stack pointer up and down between the corresponding stack frames. Everything seems to work fine - though I haven't used coroutines in serious projects yet. Now I remember to have read that (in POSIX?) no valid data should be stored *below* the current position of the stack pointer. Is that really the case? I can't find any conclusive information about that. This switching between stack frames, as described above, of course leaves temporarily suspended stack frames *below* the stack pointer, while it points into a higher frame. Does this mean that the operating system might dispose or overwrite them? For example, when paging is required? Interrupts are probably not a problem, as they push their contexts on the system stack. Some sources say that even GCC stores (small amounts of) data below the stack pointer, while others (possibly some ABIs from Intel) say this is an absolute no-no. Can anybody point to a definite answer? ♪♫ Alex -- UNSUBSCRIBE: mailto:email@example.com?subject=Unsubscribe