rusage and pthreads
materribile at yahoo.com
Wed Jan 19 00:20:03 UTC 2011
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?
More information about the freebsd-questions