[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Threads
IIRC, LispWorks for Windows among others uses a hack whereby each Lisp
thread is associated with a genuine native thread, but constrained
such that only one of them can be actively executing in Lisp at any
given time. Under that scheme, a blocking native call isn't a problem
as long as the calling thread is flagged as not being in Lisp before
the native library function is entered.
Scheduling between Lisp-mode threads eligible to run could be achieved
most simply by making them "cooperatively preemptive" in some way;
e.g. by taking the hit of adding lightweight reschedule-point checks
at function entry points and in loops (triggered either by counting or
by a timer on a utility thread). Because this brings with it the
sledgehammer synchronization primitive that is "without-preemption",
you could probably get Goo running stably using this approach in
pretty short order.
If your threads are lightweight (i.e. a single native thread exists
that manages a number of lightweight thread objects, perhaps more
typical in VM-based implementations), the choices are limited. You
pretty much have to farm out native calls to other native threads
dedicated to that chore in order to keep moving. Once the generic
infrastructure's in place though, writing native methods in that
environment isn't much more difficult than it is anywhere else.
-- Keith