Re: Are PicoLisp's coroutine stacks legal?

2013-05-26 Thread Alexander Burger
On Tue, May 21, 2013 at 07:21:12PM +0200, Rand Dow wrote: > Yes, by all means, keep the coroutines! OK, good! I've kept them :) Fixed some bugs, like -- incorrect handling of inter-coroutine catch/throw, -- files handle leaks when stopping suspended coroutines, and -- a fatal one, where

Re: Are PicoLisp's coroutine stacks legal?

2013-05-21 Thread Rand Dow
Hi Alex, Yes, by all means, keep the coroutines! Perhaps add some of this mailing list chain as a caveat about the stack in the coroutines documentation: http://picolisp.com/5000/!wiki?coroutines In particular, the picture of the stack and the warning to allocate enough stack if there is any chan

Re: Are PicoLisp's coroutine stacks legal?

2013-05-21 Thread Alexander Burger
Hi Rand, > > Is that picture a single, contiguous memory region? Because then, Yes > you *could* have the first scenario I mentioned in a previous mail > (unlikely, but, think of a native C code, that allocated huge > structures and recursed -- it could overwrite many megabytes of Yes, I'm awar

Re: Are PicoLisp's coroutine stacks legal?

2013-05-21 Thread Rand Dow
Hi Alex, On Tue, May 21, 2013 at 7:46 AM, Alexander Burger wrote: > > > To make things more clear, let's consider the following situation. It is > after the program started two coroutines, and then execution continued > in the main program. The two coroutines are suspended, and the hardware > stac

Re: Are PicoLisp's coroutine stacks legal?

2013-05-21 Thread Alexander Burger
On Tue, May 21, 2013 at 01:46:13PM +0200, Jorge Acereda Maciá wrote: > Hi, > > On May 21, 2013, at 7:46 AM, Alexander Burger wrote: > > > The big question is: Will the system (which system?) do that? If so, how > > do other languages implement green threads, coroutines or continuations? > > Som

Re: Are PicoLisp's coroutine stacks legal?

2013-05-21 Thread Jorge Acereda Maciá
Hi, On May 21, 2013, at 7:46 AM, Alexander Burger wrote: > The big question is: Will the system (which system?) do that? If so, how > do other languages implement green threads, coroutines or continuations? Some OSs do provide the required functionality (e.g, the fibers API on Windows). On POS

Re: Are PicoLisp's coroutine stacks legal?

2013-05-21 Thread Jorge Acereda Maciá
Hi, On May 21, 2013, at 6:56 AM, Alexander Burger wrote: > > They talk about "task stacks" and "preserved on this stack". I assume > that these "stacks" all reside on the single hardware stack, right? So > there is a stack *frame* for each task, and this frame might also be > used to save except

Re: Are PicoLisp's coroutine stacks legal?

2013-05-20 Thread Alexander Burger
Hi Rand, > > the user stack, there should be sufficient space. As I said, we have 1 > > MB per stack frame, and this can be easily extended with the 'stack' > > function. > > The hardware (CPU) will write at least two words (instruction pointer > and CPU status register, and maybe more) onto the

Re: Are PicoLisp's coroutine stacks legal?

2013-05-20 Thread rand
Hi Alex, On May 21, 2013, at 7:02 AM, Alexander Burger wrote: > On Tue, May 21, 2013 at 05:56:52AM +0200, Rand Dow wrote: >> Each co-routine should have it's own separate stack. Best practices with >> stack management today have a sufficiently large stack that grows and then >> terminates in unm

Re: Are PicoLisp's coroutine stacks legal?

2013-05-20 Thread Alexander Burger
Hi Rand, On Tue, May 21, 2013 at 05:56:52AM +0200, Rand Dow wrote: > Each co-routine should have it's own separate stack. Best practices with > stack management today have a sufficiently large stack that grows and then > terminates in unmapped memory. If it is attempted to grow the stack too OK.

Re: Are PicoLisp's coroutine stacks legal?

2013-05-20 Thread Alexander Burger
Hi Jorge, > I can only say that under AmigaOS it would certainly be a no-no: > > http://wiki.amigaos.net/index.php/Exec_Tasks#Task_Exceptions > ... > http://wiki.amigaos.net/index.php/Exec_Tasks#Task_Stack No. From what I read there, I believe that they do it the same way I do. They talk about

Re: Are PicoLisp's coroutine stacks legal?

2013-05-20 Thread Rand Dow
I won't try to "point" to documentation Each co-routine should have it's own separate stack. Best practices with stack management today have a sufficiently large stack that grows and then terminates in unmapped memory. If it is attempted to grow the stack too much, then the program gets a memor

Re: Are PicoLisp's coroutine stacks legal?

2013-05-20 Thread Jakob Eriksson
Wow, I just have to comment this. Amiga + picolisp in the same post = awesome. /me crawls back under rock On May 20, 2013 at 11:13 PM "Jorge Acereda Maciá" wrote: > Hi, > > I can only say that under AmigaOS it would certainly be a no-no: > -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject

Re: Are PicoLisp's coroutine stacks legal?

2013-05-20 Thread Jorge Acereda Maciá
Hi, I can only say that under AmigaOS it would certainly be a no-no: http://wiki.amigaos.net/index.php/Exec_Tasks#Task_Exceptions "When an exception occurs, Exec stops executing the tasks normal code and jumps immediately into the exception routine, no matter what the task was doing. The excep

Are PicoLisp's coroutine stacks legal?

2013-05-20 Thread Alexander Burger
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 st