检查处理器状态-检查处理器/CPU 状态和故障/关闭状态

检查处理器状态-检查处理器/CPU 状态和故障/关闭状态

我想检查处理器状态 - 检查处理器/CPU 状态和故障/关闭状态,因此我使用命令 prtdiag 并希望仅从中获取 CPU 状态。我该怎么做?

答案1

只需使用 psrinfo。

$ psrinfo 
0       on-line   since 07/21/2013 05:13:26
1       on-line   since 07/21/2013 05:13:24

但是如果您确实想检查处理器状态,那么请使用 kstat 或正确的系统调用:

System Calls                                    processor_info(2)

NAME
     processor_info - determine type and status of a processor

SYNOPSIS
     #include <sys/types.h>
     #include <sys/processor.h>

     int        processor_info(processorid_t         processorid,
     processor_info_t *infop);

DESCRIPTION
     The processor_info() function returns the status of the pro-
     cessor  specified  by  processorid  in  the processor_info_t
     structure pointed to by infop.

     The  structure  processor_info_t  contains   the   following
     members:

     int      pi_state;
     char     pi_processor_type[PI_TYPELEN];
     char     pi_fputypes[PI_FPUTYPE];
     int      pi_clock;

     The pi_state member is the current state of  the  processor,
     either P_ONLINE, P_OFFLINE, P_NOINTR, P_FAULTED, P_SPARE, or
     P_POWEROFF.

     The pi_processor_type  member  is  a  null-terminated  ASCII
     string specifying the type of the processor.

     The pi_fputypes member is  a  null-terminated  ASCII  string
     containing the comma-separated types of floating-point units
     (FPUs) attached to the processor. This string will be  empty
     if no FPU is attached.

     The pi_clock member is the processor clock frequency rounded
     to the nearest megahertz. It may be  0 if not known.

RETURN VALUES
     Upon successful completion, 0 is returned. Otherwise,  -1 is
     returned and  errno is set to indicate the error.

相关内容