chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] simple threading


From: Matthew David Parker
Subject: [Chicken-users] simple threading
Date: Fri, 16 Jun 2006 14:27:34 -0400 (EDT)

I have a computationaly heavy procedure which creates a list of 20
pointers to generated images.  My main program cycles through these images
in the list "images".  It takes a long time to run my procedure
"make-images", so while my program is animating the images in "images", I
would like to run "make-images" and have it fill up a list for the next
set of images, "next-images".  This way when I want to switch to the next
animation, I just hit the space bar and it frees the images in "images",
(set! images next-images), and then fills up "next-images" with the next
set of images.

I was trying to do this with
(process-fork make-images-thunk)

and in make-images-thunk I do:
        (set! next-images (make-images ...))

The problem with this method is that fork apparently duplicates the memory
of the parent process for the new child process, so when I call set! it's
setting the child's "next-images" and is not the real "next-images" which
is a global in the parent process; my main program.

Then I also tried to use SRFI-18 but when I started my thread to make the
images, it waited a few seconds before it did the thread, and then it
started the thread, and devoted the entire CPU to making the images, so
that the animation stopped.

I think SRFI-18 might not be useful to me, because the computationally
intensive part is calling some C function to manipulate the image, and I
wouldn't want to put "thread-yield!" into the C function.

Does anyone know a clever solution to my problem?

Matt







reply via email to

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