getting particular thread cpu time

Daniel Eischen deischen at
Wed Feb 1 05:33:52 PST 2006

On Wed, 1 Feb 2006, Ilya E Veretenkin wrote:

> Hello.
> I am writing a multi-threaded application and want to see the cpu
> usage of each thread of this application.
> I know that 'ps -H' outputs cpu usage information for threads, but how
> can I found out the correspondence between particular thread in 'ps-H'
> output and particular thread ID in my application?

You can't, unless:

  1) Every thread is system scope; or
  2) You use libthr where every thread maps 1:1 to a kernel thread

Even then, I don't know whether CPU usage is maintained correctly
yet by the kernel for a multi-threaded process.  Someone has been
working on it recently.

Libpthread is M:N by default, so the kernel doesn't know about
userland threads.


More information about the freebsd-threads mailing list