void print_all_mutex(lockgroup_info_t *lockgroup) { unsigned int i; for (i = 0;i < count;i++) print_mutex(i, lockgroup); printf("\n"); }
static int mutex_stats_show(struct seq_file *m, void *v) { SEQ_printf(m, "ChronOS Version: %s, %s %.*s\n", CHRONOS_VERSION_STRING, init_utsname()->release, (int)strcspn(init_utsname()->version, " "), init_utsname()->version); print_mutex(m); SEQ_printf(m, "\n"); return 0; }
int main(int argc, char **argv) { kern_return_t kr; int arg2; unsigned int i; int found; setlinebuf(stdout); pgmname = argv[0]; gDebug = (NULL != strstr(argv[0], "debug")); host_control = mach_host_self(); kr = host_lockgroup_info(host_control, &lockgroup_info, &count); if (kr != KERN_SUCCESS) { mach_error("host_statistics", kr); exit (EXIT_FAILURE); } if (gDebug) { printf("count = %d\n", count); for (i = 0; i < count; i++) { printf("%s\n",lockgroup_info[i].lockgroup_name); } } switch (argc) { case 2: if (strcmp(argv[1], "all") == 0) { print_spin_hdr(); print_all_spin(lockgroup_info); print_mutex_hdr(); print_all_mutex(lockgroup_info); print_rw_hdr(); print_all_rw(lockgroup_info); } else if (strcmp(argv[1], "spin") == 0) { print_spin_hdr(); print_all_spin(lockgroup_info); } else if (strcmp(argv[1], "mutex") == 0) { print_mutex_hdr(); print_all_mutex(lockgroup_info); } else if (strcmp(argv[1], "rw") == 0) { print_rw_hdr(); print_all_rw(lockgroup_info); } else { found = 0; for (i = 0;i < count;i++) { if (strcmp(argv[1], lockgroup_info[i].lockgroup_name) == 0) { found = 1; print_spin_hdr(); print_spin(i, lockgroup_info); print_mutex_hdr(); print_mutex(i, lockgroup_info); print_rw_hdr(); print_rw(i, lockgroup_info); break; } } if (found == 0) { usage(); } } break; case 3: if (sscanf(argv[2], "%d", &arg2) != 1) { usage(); } if (arg2 < 0) { usage(); } prime_lockgroup_deltas(); if (strcmp(argv[1], "all") == 0) { while (1) { sleep(arg2); get_lockgroup_deltas(); print_spin_hdr(); print_all_spin(lockgroup_deltas); print_mutex_hdr(); print_all_mutex(lockgroup_deltas); print_rw_hdr(); print_all_rw(lockgroup_deltas); } } else if (strcmp(argv[1], "spin") == 0) { while (1) { sleep(arg2); get_lockgroup_deltas(); print_spin_hdr(); print_all_spin(lockgroup_deltas); } } else if (strcmp(argv[1], "mutex") == 0) { while (1) { sleep(arg2); get_lockgroup_deltas(); print_mutex_hdr(); print_all_mutex(lockgroup_deltas); } } else if (strcmp(argv[1], "rw") == 0) { while (1) { sleep(arg2); get_lockgroup_deltas(); print_rw_hdr(); print_all_rw(lockgroup_deltas); } } else { found = 0; for (i = 0;i < count;i++) { if (strcmp(argv[1], lockgroup_info[i].lockgroup_name) == 0) { found = 1; while (1) { sleep(arg2); get_lockgroup_deltas(); print_spin_hdr(); print_spin(i, lockgroup_deltas); print_mutex_hdr(); print_mutex(i, lockgroup_deltas); print_rw_hdr(); print_rw(i, lockgroup_deltas); } } } if (found == 0) { usage(); } } break; case 4: if (strcmp(argv[3], "abs") != 0) { usage(); } if (sscanf(argv[2], "%d", &arg2) != 1) { usage(); } if (strcmp(argv[1], "all") == 0) { while (1) { print_spin_hdr(); print_all_spin(lockgroup_info); print_mutex_hdr(); print_all_mutex(lockgroup_info); print_rw_hdr(); print_all_rw(lockgroup_info); sleep(arg2); } } else if (strcmp(argv[1], "spin") == 0) { while (1) {print_all_spin(lockgroup_info); sleep(arg2); } } else if (strcmp(argv[1], "mutex") == 0) { print_mutex_hdr(); while (1) {print_all_mutex(lockgroup_info); sleep(arg2); } } else if (strcmp(argv[1], "rw") == 0) { print_rw_hdr(); while (1) {print_all_rw(lockgroup_info); sleep(arg2); } } else { found = 0; for (i = 0;i < count;i++) { if (strcmp(argv[1], lockgroup_info[i].lockgroup_name) == 0) { found = 1; while (1) { print_spin_hdr(); print_spin(i, lockgroup_info); print_mutex_hdr(); print_mutex(i, lockgroup_info); print_rw_hdr(); print_rw(i, lockgroup_info); sleep(arg2); } } } if (found == 0) { usage(); } } break; default: usage(); break; } exit(0); }