Hi Rand,

> > Is that picture a single, contiguous memory region? Because then,


> 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 aware of that. I wrote something similar also in my mail
earlier today:

   This doesn't happen usually. PicoLisp does runtime stack checks, so the
   above would result in an stack overflow error (I say "usually", because
   this is not 100% safe. You may call some 'native' code which does
   unpredictable things to the stack, for example).

> would have to have a very clear picture of the above to know to use
> the 'stack' function to allocate adequate stack.

Yep. That's the trade-off. As soon as you use a coroutine in PicoLisp,
you have to be concious about your stack. For a program that has no
coroutine active when a lot of stack space is needed, these limitations
don't apply. As soon as the last coroutine finishes or is stopped, the
stack becomes unlimited again (at least if you called "ulimit -s

> Anyway, enough is *not ever* enough. I would only feel comfortable
> seeing at least 10MB of *non-mapped* memory between the main program's
> stack and each of the the co-routines' stacks.

Then you could call (stack 3) before starting the first coroutine. This
allocates 12 MB for the main task, and 3 MB for each coroutine.

> Again, generally, I would feel uncomfortable having anything "below"
> my stack pointer than a large region of writable memory followed
> by a very large region of memory that would give me a "sigsegv" if
> I tried to access it. If I am the application programmer, I can
> violate these rules, but as the "language system programmer" (i.e.,
> you) you can never make assumptions about how that application
> programmer is going to use the stack.


> > The big question is: Will the system (which system?) do that? If so, how
> > do other languages implement green threads, coroutines or continuations?
> >
> > Since that is read/write memory, the system won't purge it. It might
> be paged out (to swap), but would be transparently paged back in
> if/when used again. I'd never expect an OS to "know" that a region
> of memory is a stack.

Great! That's good news.

So let's keep the coroutines in PicoLisp, unless somebody objects. :)

♪♫ Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to