Hi I''m new in dtrace programming. Can anyone tell me how pctcpu work. I saw pankaj said that "Brendan showed me how to get the pctcpu using curthread->t_pctcpu". Can anyone tell me it? Thanks Leslie This message posted from opensolaris.org
It''s approximately the % of the thread''s time spent running on a CPU. t_pctcpu is 32-bit scaled. To get it in the range of [0,1] you''ll need to divide by 0x80000000 -Eric This message posted from opensolaris.org
On Tue, Apr 11, 2006 at 12:46:56AM -0700, leslie wrote:> Hi > > I''m new in dtrace programming. Can anyone tell me how pctcpu work. I > saw pankaj said that "Brendan showed me how to get the pctcpu using > curthread->t_pctcpu". Can anyone tell me it?curthread->t_pctcpu is a scaled 32-bit integer <= 1. To get the percentage, you''d do something like: printf("%d", curthread->t_pctcpu / ((1U << 31) / 100)); Note that ''%CPU'' reported in ps(1) and prstat(1) are scaled by the number of online CPUs in the system; this isn''t doing that scaling. Also, this is all private implementation details which can change in any patch. You might want to file an RFE to get pr_pctcpu in the D lwpsinfo_t translator. Cheers, - jonathan -- Jonathan Adams, Solaris Kernel Development
Hi jonathan Thanks for your reply. Could you please provide some scripts using curthread->t_pctcpu? Thanks Best Regards Leslie (Wang Qi) -----Original Message----- From: dtrace-discuss-bounces at opensolaris.org [mailto:dtrace-discuss-bounces at opensolaris.org] On Behalf Of Jonathan Adams Sent: 2006?4?12? 2:30 To: leslie Cc: dtrace-discuss at opensolaris.org Subject: Re: [dtrace-discuss] how does pctcpu work? On Tue, Apr 11, 2006 at 12:46:56AM -0700, leslie wrote:> Hi > > I''m new in dtrace programming. Can anyone tell me how pctcpu work. I > saw pankaj said that "Brendan showed me how to get the pctcpu using > curthread->t_pctcpu". Can anyone tell me it?curthread->t_pctcpu is a scaled 32-bit integer <= 1. To get the curthread->percentage, you''d do something like: printf("%d", curthread->t_pctcpu / ((1U << 31) / 100)); Note that ''%CPU'' reported in ps(1) and prstat(1) are scaled by the number of online CPUs in the system; this isn''t doing that scaling. Also, this is all private implementation details which can change in any patch. You might want to file an RFE to get pr_pctcpu in the D lwpsinfo_t translator. Cheers, - jonathan -- Jonathan Adams, Solaris Kernel Development _______________________________________________ dtrace-discuss mailing list dtrace-discuss at opensolaris.org