unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Warning: Unstable POSIX threads support comitted to CVS
@ 2002-12-09 13:44 Mikael Djurfeldt
  2002-12-09 14:26 ` Marius Vollmer
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Djurfeldt @ 2002-12-09 13:44 UTC (permalink / raw)
  Cc: marius.vollmer

[-- Attachment #1: Type: text/plain, Size: 2551 bytes --]

Hi,

Based on Marius copt threads work, I've now put together an initial
version of full POSIX threads support with preemptive thread
scheduling.  This is especially good to have if you, like me, use
multi-cpu machines.

Attached to this letter is an example program:

  par-fib N DEPTH --> fibonacci number N

The number is computed by forking to DEPTH levels.
For example, (par-fib 100 4) creates 31 threads (with 16 threads at
the base level, reverting to iterative computation of the rest).
(par-fib 100 5) crashes for me... :)

Well, yes, the current state of the code is slightly broken.  Just as
before this change, the null-threads alternative won't build, and the
threading alternative is the default.  The idea is that we for the
coming couple of weeks can make a collaborative effort of finding bugs
and fundamental problems.

However, single-thread use seems stable (although there could be some
problems with errors in macro transformers).

We need to work on signal delivery and exceptions.  One suggestion is
that we continue to *only* deliver signals at SCM_ASYNC_TICK points.
The effect of signal delivery (normally a throw) is then pretty well
controlled.  A novel (?) suggestion is this:

It is very irritating that signals are delivered to whatever thread
happens to run for the moment.  Is it possible to add explicit
interactive control over which thread is the "foreground" thread?
Only the "foreground" thread gets signal delivery (=> that thread gets
its async lists marked regardless of which thread reacted on the
signal).  Normally, the "foreground" is the repl loop thread, and we
can have a small "command language" (perhaps ordinary scheme
procedures) to inspect status of the other threads and explicitly
deliver signals like "SIGINT".

One further area which needs work is the current recursive critical
sections (SCM_REDEFER/REALLOW_INTS, SOURCE_SECTION in eval.c etc).
They need to be optimized (use real POSIX recursive mutecis if
available).  We should also add a mechanism for resetting (unlocking)
the associated mutecis on an error throw.  This can be made by adding
a line for registering the critical section in
SCM_REC_CRITICAL_SECTION in snarf.h.

I and Marius hope to fix the most basic problems within a few days.
Then I think we'll have an acceptable level of stability.  And, as
Marius have said before, the thread suppport is in a state of flux.
Much can still change...

(BTW, there seems to be some unrelated build problem right now due to
the recent change to versioning.)

Best regards,
Mikael D.


[-- Attachment #2: Thread test program --]
[-- Type: text/plain, Size: 370 bytes --]

(define (par-fib n n-forks)
  (cond ((<= n 1) 1)
	((> n-forks 0)
	 (letpar ((f1 (par-fib (- n 1) (- n-forks 1)))
		  (f2 (par-fib (- n 2) (- n-forks 1))))
	   (+ f1 f2)))
	(else
	 (let ((f1 (mono-fib (- n 1)))
	       (f2 (mono-fib (- n 2))))
	   (+ f1 f2)))))

(define (mono-fib n)
  (let iter ((f1 1) (f2 1) (i 1))
    (if (>= i n)
	f2
	(iter f2 (+ f1 f2) (+ 1 i)))))

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-12-09 17:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-09 13:44 Warning: Unstable POSIX threads support comitted to CVS Mikael Djurfeldt
2002-12-09 14:26 ` Marius Vollmer
2002-12-09 17:40   ` Mikael Djurfeldt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).