1

I have a small daemon that I'm writing in C and I need a way to get the current CPU time on a thread. Linux apparently supplies a number of ways to go about doing this, clock_gettime(CLOCK_THREAD_CPUTIME_ID, ...), pthread_getcpuclockid(), getrusage(RUSAGE_THREAD, ...) but none of these seem to be supported under OpenSolaris 2009.06.

Is there a cross-platform friendly way to get the current CPU time for a thread? If not, is there any way to do it in OpenSolaris at all? At this point, I'm even willing to put in a bunch of ugly compiler directives to make this work.

lazyconfabulator
  • 477
  • 2
  • 6
  • 13

1 Answers1

0

According to "Thread Priority on the Solaris Platform", Solaris 9 and above default to a one-to-one correspondence between threads and LWPs (Light-Weight Processes). Therefore, according to getrusage's manpage, you should be able to call getrusage(RUSAGE_LWP, ...).

alanc
  • 4,102
  • 21
  • 24
Josh Kelley
  • 56,064
  • 19
  • 146
  • 246