Skip to content

Instantly share code, notes, and snippets.

@kinichiro
Created August 14, 2014 02:09
Show Gist options
  • Save kinichiro/0c6e66d43fc1f9c2d317 to your computer and use it in GitHub Desktop.
Save kinichiro/0c6e66d43fc1f9c2d317 to your computer and use it in GitHub Desktop.
sample code for pstat_getprocessor()
/* test_pstat_getprocessor.c */
#include <stdio.h>
#include <sys/pstat.h>
int main() {
int i;
for(i = 0; i < PST_MAX_PROCS; ++ i) {
struct pst_processor buf;
if(pstat_getprocessor(&buf, sizeof(buf), 1, i) != 1) {
continue;
}
printf("++++++++++----------++++++++++----------++++++++++----------\n");
printf("Index of the current spu = %d\n", buf.psp_idx);
printf("# of reads from filesys blocks. = %d\n", buf.psp_fsreads);
printf("# of writes to filesys blocks. = %d\n", buf.psp_fswrites);
printf("# of physical reads from raw devs. = %d\n", buf.psp_phread);
printf("# of physical writes to raw devs. = %d\n", buf.psp_phwrite);
printf("# of times the processor had processes waiting to run. = %d\n", buf.psp_runocc);
printf("# of processes the processor had waiting to run. = %d\n", buf.psp_runque);
printf("# of exec system calls. = %d\n", buf.psp_sysexec);
printf("# of read system calls. = %d\n", buf.psp_sysread);
printf("# of write system calls. = %d\n", buf.psp_syswrite);
printf("# of raw characters read. = %d\n", buf.psp_ttyrawcnt);
printf("# of canonical chars processed. = %d\n", buf.psp_ttycanoncnt);
printf("# of characters output. = %d\n", buf.psp_ttyoutcnt);
printf("interval timer counts (CR16) per clock tick = %d\n", buf.psp_iticksperclktick);
printf("# of select system calls. = %d\n", buf.psp_sysselect);
printf("cpu core frequency = %d\n", buf.psp_cpu_frequency);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment