chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Posix threading


From: Julian Morrison
Subject: Re: [Chicken-users] Posix threading
Date: Fri, 11 Mar 2005 00:53:21 +0000
User-agent: Debian Thunderbird 1.0 (X11/20050116)

Toby Butzon wrote:

I'm new to "real" Scheme programming[1], but I'm quite surprised
that it doesn't use posix/native threading.

Some of the interpreted schemes probably do. I haven't looked. Posix threading with dynamic code is perfectly possible, I know that java and ocaml both use Posix threads.

It seems like a wacky
idea to have threads that can't be scheduled on separate CPUs, or
worse, that block the entire process on a blocking system call
(surprising since this is one of the major ways threads are used
in other languages).
Better than not having any threads. Many blocking kernel calls can be emulated via nonblocking IO. (This obviously fails when calling out to external code which does not use scheme's IO primitives.)

Apologies in advance if these are stupid questions, but what am I
missing?

Chicken's GC mechanism.

If I read the docs right, what it does is approximately:
- convert function calls from call-and-return to continuation-passing-style
- allocate all objects on stack
- when the stack gets too big, copy all reachable stack objects to heap, and unwind the stack
- periodically do a copying GC in heap

Problems:
- Posix threads have seperate stacks. Stack allocated objects in one thread are unreachable from others. - Copying GC moves pointers in heap. If one thread does a copying GC, the others won't know where the pointers moved.

Possible solutions, respectively:
- Do a minor GC as though stack space had run out, before starting each Posix thread.
- Either
--- access pointers indirectly through some means which makes their movement in heap transparent (evicted locatives?), --- or provide a mechanism to temporarily lock current (to be shared) objects against GC, which is called before any threading.


Is it just that scheme semantics make it hard?
More like, continuations make userspace threads easy.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]