POV-Ray : Newsgroups : povray.off-topic : My toy : Re: My toy Server Time
6 Sep 2024 11:16:29 EDT (-0400)
  Re: My toy  
From: Darren New
Date: 8 Mar 2009 19:21:59
Message: <49b45317@news.povray.org>
Chambers wrote:
> Not quite; you COULD implement scheduling / task switching in a single 
> thread.  It would just be too much hassle when real threading is available.

Actually, if you get a good library for it, it can be beneficial in several 
ways.

For example, Erlang does this (one thread per core) and supports hundreds of 
thousands of concurrent threads (which would easily blow the stack and the 
scheduler if you used OS threads).

Tcl uses this approach (unless you opt for threads, of course) with the 
advantage that events that occur are serialized, so you can write code to 
handle events coming in from sockets that update shared globals without 
worrying about locks. Of course, if you have multiple cores, you're kind of 
screwed performance-wise with this approach, which is why Tcl supports real 
threads as well. Works great on a single CPU per process, tho.

The drawback is that without continuations as well (Tcl doesn't do lambdas 
any better than C++ does), it's hard to coordinate stuff sometimes, because 
you're always coming in at the top level. You have to turn all your loops 
inside out, basically.

I was thinking of looking at the Python asyncore module (which is what does 
this sort of thing for Python) and seeing if I could combine it with yield 
and send() to make lightweight isolated threads. Would be very cool.

-- 
   Darren New, San Diego CA, USA (PST)
   My fortune cookie said, "You will soon be
   unable to read this, even at arm's length."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.