[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] process-wait
From: |
Alan Post |
Subject: |
Re: [Chicken-users] process-wait |
Date: |
Thu, 1 Sep 2011 11:43:24 -0600 |
On Thu, Sep 01, 2011 at 10:02:18AM -0700, address@hidden wrote:
> Hello,
> > ***** Message sent: 01 Sep 2011 14:16:44 +0200 *****
> > For quite some time I've been wondering why my app runs only about
> > twice as fast on chicken compared to rscheme (given the benchmark
> > style performance of chicken code).
> > strace was my friend to pin this down to process-wait. From the
> > manual: "Suspends the current process...Note that suspending the
> > current process implies that all threads are suspended as well."
> > Too bad, my app spent it's time waiting for irrelevant processes,
> > not running useful threads as I'd like it to.
> > This shouldn't be too hard to fix, I thought - and wrote the code
> > I'll paste and comment. (With the intention that this might
> > go into the posix unit eventually.) Once the issues I have are
> > resolved, that is. However those are harder than I expected:
> > (Side note: even with bad the code here my app feels much
> > better, since the "coughing" is gone.)
> ...
> > The idea is to convert (process-wait pid #f) into
> > (process-wait pid #t) and block the current tread only
> > when the first result is zero.
> Sounds indeed frustrating. I've run across similar problems while writing
> a multitasking web server. It uses process-fork to create child processes
> which handle the client requests. Under Linux, the parent may wait, or
> not, for the child to finish, If not, the child doesn't "go away"--it's a
> "zombie"--until the parent ends, unless the default signal handler flags
> are set to a NOWAIT value.
If NOWAIT is not yes, you need to capture the SIGCHLD signal and
call waitpid(2) (or a related function) to collect the exit status
of a terminated child process. A "zombie" process is one which is
terminated but is storing this information for the parent process.
So, what you say is true. :-)
-Alan
--
.i ma'a lo bradi cu penmi gi'e du