From owner-freebsd-questions@FreeBSD.ORG Wed Jan 19 00:20:03 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2DE32106566C for ; Wed, 19 Jan 2011 00:20:03 +0000 (UTC) (envelope-from materribile@yahoo.com) Received: from nm8.bullet.mail.sp2.yahoo.com (nm8.bullet.mail.sp2.yahoo.com [98.139.91.78]) by mx1.freebsd.org (Postfix) with SMTP id 0B5C48FC12 for ; Wed, 19 Jan 2011 00:20:03 +0000 (UTC) Received: from [98.139.91.68] by nm8.bullet.mail.sp2.yahoo.com with NNFMP; 19 Jan 2011 00:07:18 -0000 Received: from [98.139.91.17] by tm8.bullet.mail.sp2.yahoo.com with NNFMP; 19 Jan 2011 00:07:18 -0000 Received: from [127.0.0.1] by omp1017.mail.sp2.yahoo.com with NNFMP; 19 Jan 2011 00:07:18 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 538189.9983.bm@omp1017.mail.sp2.yahoo.com Received: (qmail 36160 invoked by uid 60001); 19 Jan 2011 00:07:18 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1295395638; bh=aM0wZapWcZwS4JbT4K/1wQgvpi9erGx8KCZFL9xuKNc=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=QQl12ojnvpiQZaDzOmkUd+G57nrY+NrARq+fXpJsMzR/YRpw7b7AvkRndC3yNdO8HVktXjmg30hbxtJ+Tmo5WQG6CMQQDiXe/untxLAeiBzkg2Q5em+G7hH8LFlBhcT24sfXoPzk/23USzV2qXO+JpdjwTUEXvK5EvU8slcuBJA= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=RB4Xkejs453BfyxkuYew/nEGDN37tq6lAGlpYk3qPMs+E/m+nga3c1oX835euzkKhNOVU41rkVkqxsRcUma3w+XAkbl1ATmZeeluTvok5fyw3e72RNtuTfOnRw9jsMq49rpNsngVcIw4GPvuYghBX0a2KWBBkzBDvAmqPqUo3wM=; Message-ID: <57927.35211.qm@web110302.mail.gq1.yahoo.com> X-YMail-OSG: YKUzDn8VM1nLjlo4l_AAJQytC5F4VLJ.PVQkEL8bNJiDkVQ syrRve.tnM8Klzh0uycSxiietqvAAESL3ufulIcbU6vfmTz6RQ8J0I9W_f.. demQo9jR6IuLOA4ZkNvBB4OXAd.gt9xVwwDvYaCQl2RfK5lhWiNU7q.0RtX3 m7jIhjtQRnKSjoAw5.VRF8DTQvsMOfducDDjAqsmBXPGPG.ITFxbTVSZ4Fb6 pnREMzbZBCL58Wxg2xvmciBvmSfNco1OEmYrDIf.Z96lgPxFKzJ3u6wLXgNa YtPZjyaCQBePtZA6wyq1I0r5sNVmDgEFmoneLi0TWGaJfc9LnjfuMMPvFBTd 52umL23_XFnjOkhjG4GWGsmkUi_k3Dp96jQhrgxSR8Ny9kIuhK1_lUFLWYI4 ahHRaRvvSp_qi Received: from [24.228.57.153] by web110302.mail.gq1.yahoo.com via HTTP; Tue, 18 Jan 2011 16:07:17 PST X-Mailer: YahooMailClassic/11.4.20 YahooMailWebService/0.8.107.285259 Date: Tue, 18 Jan 2011 16:07:17 -0800 (PST) From: Mark Terribile To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: rusage and pthreads X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jan 2011 00:20:03 -0000 Hi, I'm trying to figure out the interactions between rusage and pthreads. Peeking around in the kernel (7.2) I see updates occurring in various places. kern_clock.c, for instance, appears to increment the memory occupancy (*rss) counters. This would make it appear that every thread gets part of the count, but also that only the process that happens to have the CPU at that moment gets its count updated, even if it holds the memory. Am I misreading this? And the context switch counters also appear to be updated per-thread, but in mi_switch(), in kern_synch.c. Is this true? If the answer is "yes, it's per-thread", then how does a process report its usages without putting the requisite code in each thread, along with the machinery to divert from whatever the thread is doing (even waiting on I/O) to get the report at (nearly) the same time in all threads? Is there a big design hole here? Mark Terribile