in reply to Threads, Forks, or Nothing?

There are three ways you can achieve multiprocessing:

  1. Heavyweight processes, using pipes or other IPC, as mentioned above. Awkward.
  2. Lightweight processes, using Perl threading, hoping that everything you use is re-entrant and thread safe. Dangerous.
  3. User space processes, where code surrenders control of the processor to other pieces of code once it has had a "fair turn". POE is an excellent framework for achieving this without getting too much of a headache.

You don't need kernel threads to write multithreaded applications. You just need to break your problem up in to chunks, build a little "run-queue" of waiting chunks of code, make sure all your system calls are non-blocking, and have a loop that picks the first chunk off the queue and runs it. In many cases, this type of threading may actually outperform kernel enforced lightweight processes. Sure, you might still hang somewhere if you've a bug, but that's always the case, isn't it?