/* cc -o proc_info proc_info.c * * A simple program to display info for each processor * on Sun machines. * * Author: Paul Farrall pfarrall@brains2bytes.com * Copyright 2002 Paul Farrall * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * */ #include #include #include #include #include processor_info_t infop; processorid_t processorid; int main(void) { int ret = 0; char state[10]; int num_processors = sysconf(_SC_NPROCESSORS_CONF); for (processorid=0; num_processors > 0; processorid++) { ret = processor_info(processorid, &infop); if ( ret == -1 && errno == EINVAL ) /* proc doesn't exist */ continue; switch (infop.pi_state) { case P_ONLINE: strcpy(state, "online"); break; case P_OFFLINE: strcpy(state, "offline"); break; case P_POWEROFF: strcpy(state, "poweroff"); break; default: strcpy(state, "unknown"); } printf("Proc=%d, state=%s, type=%s, fpu=%s, speed=%d\n", processorid, state, infop.pi_processor_type, infop.pi_fputypes, infop.pi_clock); num_processors--; } return; }