Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 85238 invoked from network); 22 Sep 2006 00:03:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Sep 2006 00:03:33 -0000 Received: (qmail 88954 invoked by uid 500); 22 Sep 2006 00:03:33 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 88878 invoked by uid 500); 22 Sep 2006 00:03:33 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 88848 invoked by uid 99); 22 Sep 2006 00:03:32 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Sep 2006 17:03:32 -0700 Authentication-Results: idunn.apache.osuosl.org smtp.mail=sebor@roguewave.com; spf=permerror X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= Received-SPF: error (idunn.apache.osuosl.org: domain roguewave.com from 208.30.140.160 cause and error) Received: from [208.30.140.160] ([208.30.140.160:37929] helo=moroha.quovadx.com) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id 95/92-05580-E3823154 for ; Thu, 21 Sep 2006 17:03:16 -0700 Received: from qxvcexch01.ad.quovadx.com (qxvcexch01.ad.quovadx.com [192.168.170.59]) by moroha.quovadx.com (8.13.6/8.13.6) with ESMTP id k8M02W7t017184 for ; Fri, 22 Sep 2006 00:02:32 GMT Received: from [10.70.3.113] ([10.70.3.113]) by qxvcexch01.ad.quovadx.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 21 Sep 2006 18:03:05 -0600 Message-ID: <4513283C.609@roguewave.com> Date: Thu, 21 Sep 2006 18:03:08 -0600 From: Martin Sebor Organization: Rogue Wave Software User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 X-Accept-Language: en-us, en MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: incorrect runtimes References: <450B1652.10205@roguewave.com> <4512C4CF.2040802@roguewave.com> <4512EFD4.5030508@roguewave.com> <45131249.9040108@roguewave.com> <45132397.5060906@roguewave.com> In-Reply-To: <45132397.5060906@roguewave.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 22 Sep 2006 00:03:05.0837 (UTC) FILETIME=[7ABBB9D0:01C6DDDA] X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Here's another piece of info (just because I like talking to myself in public): I posted a question about the Solaris behavior to the OpenSolaris bugs forum: http://www.opensolaris.org/jive/thread.jspa?threadID=14188 Martin Sebor wrote: > Martin Sebor wrote: > >> I took a closer look at the output produced by my little test program >> (after making a small change to it where I moved the sleep(1) call in >> the parent branch immediately above the waitpid call). Here's the >> behavior I have observed on each of the following operating systems: >> > > Here's a corrected interpretation of the results (the corrected > program is attached): > > AIX: only immediate children's times are returned > HP-UX: only immediate children's times are returned > IRIX 6.5: only immediate children's times are returned > Linux: only immediate children's times are returned > Solaris: cumulative times of children and all their > descendants are returned > Tru64: only immediate children's times are returned > > I was misled by the rapidly decreasing user times in test runs > that created increasing numbers of grandchildren. The decreasing > numbers actually make sense since more processes compete for the > CPU and thus get to use it less time (with the OS spending more > of its own time switching between them). > > So I guess the only odd duck is Solaris which accumulates the > time used up by the child's children's despite the fact that > they were never waited on. > > Martin > > > ------------------------------------------------------------------------ > > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > > static void > print_usage (int who, int status) > { > struct rusage usage = { 0 }; > getrusage (who, &usage); > printf ("child exit status: %d\n" > "usr time: %lu.%06lu\n" > "sys time: %lu.%06lu\n", > status, > usage.ru_utime.tv_sec , usage.ru_utime.tv_usec, > usage.ru_stime.tv_sec , usage.ru_stime.tv_usec); > } > > int main (int argc, char *argv[]) > { > unsigned long signo = 1 < argc ? strtoul (argv [1], 0, 10) : 0; > unsigned long nsec = 2 < argc ? strtoul (argv [2], 0, 10) : 0; > unsigned long nproc = 3 < argc ? strtoul (argv [3], 0, 10) : 0; > unsigned long alrm = 4 < argc ? strtoul (argv [4], 0, 10) : 0; > pid_t child_id; > > printf ("child spawns %lu grandchildren in the same process group\n" > "each child process sets a %lu second alarm and loops forever\n" > "parent sleeps %lu seconds before sending signal %lu to group\n", > nproc, alrm, nsec, signo); > > child_id = fork (); > > if (child_id) { > int status; > sleep (nsec); > if (kill (-child_id, signo)) > fprintf (stderr, "kill(%d, %d) failed: %s\n", > -child_id, signo, strerror (errno)); > > sleep (1); > if (0 > waitpid (child_id, &status, 0)) > fprintf (stderr, "waitpid(%d, %p, 0) failed: %s\n", > child_id, &status, strerror (errno)); > > while (nproc-- && 0 == kill (-child_id, signo)); > > print_usage (RUSAGE_CHILDREN, status); > } > else { > setsid (); > > if (10 < nproc) > nproc = 10; > > while (nproc--) > if (0 == fork ()) > break; > > alarm (alrm); > > for ( ; ; ); > } > > return 0; > }