zoukankan      html  css  js  c++  java
  • /proc文件系统(一):cpuinfo

    0. 前言

    /proc 文件系统是一个伪文件系统,它只存在内存当中,而不占用外存空间。

    它以文件系统的方式为内核与进程提供通信的接口。用户和应用程序可以通过/proc得到系统的信息,并可以改变内核的某些参数。
    由于系统的信息,如进程,是动态改变的,所以用户或应用程序读取/proc目录中的文件时,proc文件系统是动态从系统内核读出所需信息并提交的。

    root@jimmy-vm:/proc# ll /proc/
    dr-xr-xr-x  9 root             root                           0 11月 28 20:09 <pid>/
    ......
    dr-xr-xr-x  2 root             root                           0 11月 30 16:53 acpi/
    dr-xr-xr-x  5 root             root                           0 11月 30 16:53 asound/
    -r--r--r--  1 root             root                           0 11月 30 16:53 buddyinfo
    dr-xr-xr-x  4 root             root                           0 11月 30 16:53 bus/
    -r--r--r--  1 root             root                           0 11月 30 16:53 cgroups
    -r--r--r--  1 root             root                           0 11月 30 16:53 cmdline
    -r--r--r--  1 root             root                           0 11月 30 16:53 consoles
    -r--r--r--  1 root             root                           0 11月 30 16:53 cpuinfo
    -r--r--r--  1 root             root                           0 11月 30 16:53 crypto
    -r--r--r--  1 root             root                           0 11月 30 16:53 devices
    -r--r--r--  1 root             root                           0 11月 30 16:53 diskstats
    -r--r--r--  1 root             root                           0 11月 30 16:53 dma
    dr-xr-xr-x  2 root             root                           0 11月 30 16:53 driver/
    -r--r--r--  1 root             root                           0 11月 30 16:53 execdomains
    -r--r--r--  1 root             root                           0 11月 30 16:53 fb
    -r--r--r--  1 root             root                           0 11月 30 16:53 filesystems
    dr-xr-xr-x  5 root             root                           0 11月 30 16:53 fs/
    -r--r--r--  1 root             root                           0 11月 30 16:53 interrupts
    -r--r--r--  1 root             root                           0 11月 30 16:53 iomem
    -r--r--r--  1 root             root                           0 11月 30 16:53 ioports
    dr-xr-xr-x 57 root             root                           0 11月 30 16:53 irq/
    -r--r--r--  1 root             root                           0 11月 30 16:53 kallsyms
    -r--------  1 root             root             140737477881856 11月 30 16:53 kcore
    -r--r--r--  1 root             root                           0 11月 30 16:53 keys
    -r--r--r--  1 root             root                           0 11月 30 16:53 key-users
    -r--------  1 root             root                           0 11月 16 14:27 kmsg
    -r--------  1 root             root                           0 11月 30 16:53 kpagecgroup
    -r--------  1 root             root                           0 11月 30 16:53 kpagecount
    -r--------  1 root             root                           0 11月 30 16:53 kpageflags
    -r--r--r--  1 root             root                           0 11月 30 16:53 loadavg
    -r--r--r--  1 root             root                           0 11月 30 16:53 locks
    -r--r--r--  1 root             root                           0 11月 30 16:53 mdstat
    -r--r--r--  1 root             root                           0 11月 30 16:53 meminfo
    -r--r--r--  1 root             root                           0 11月 30 16:53 misc
    -r--r--r--  1 root             root                           0 11月 30 16:53 modules
    lrwxrwxrwx  1 root             root                          11 11月 30 16:53 mounts -> self/mounts
    dr-xr-xr-x  3 root             root                           0 11月 30 16:53 mpt/
    -rw-r--r--  1 root             root                           0 11月 30 16:53 mtrr
    lrwxrwxrwx  1 root             root                           8 11月 30 16:53 net -> self/net/
    -r--r--r--  1 root             root                           0 11月 30 16:53 pagetypeinfo
    -r--r--r--  1 root             root                           0 11月 30 16:53 partitions
    -r--r--r--  1 root             root                           0 11月 30 16:53 sched_debug
    -r--r--r--  1 root             root                           0 11月 30 16:53 schedstat
    dr-xr-xr-x  4 root             root                           0 11月 30 16:53 scsi/
    lrwxrwxrwx  1 root             root                           0 11月 16 14:27 self -> 107692/
    -r--------  1 root             root                           0 11月 30 16:53 slabinfo
    -r--r--r--  1 root             root                           0 11月 30 16:53 softirqs
    -r--r--r--  1 root             root                           0 11月 30 16:53 stat
    -r--r--r--  1 root             root                           0 11月 16 14:27 swaps
    dr-xr-xr-x  1 root             root                           0 11月 16 14:27 sys/
    --w-------  1 root             root                           0 11月 30 16:53 sysrq-trigger
    dr-xr-xr-x  2 root             root                           0 11月 30 16:53 sysvipc/
    lrwxrwxrwx  1 root             root                           0 11月 16 14:27 thread-self -> 107692/task/107692/
    -r--r--r--  1 root             root                           0 11月 30 16:53 timer_list
    -rw-r--r--  1 root             root                           0 11月 30 16:53 timer_stats
    dr-xr-xr-x  4 root             root                           0 11月 30 16:53 tty/
    -r--r--r--  1 root             root                           0 11月 30 16:53 uptime
    -r--r--r--  1 root             root                           0 11月 30 16:53 version
    -r--r--r--  1 root             root                           0 11月 30 16:53 version_signature
    -r--------  1 root             root                           0 11月 30 16:53 vmallocinfo
    -r--r--r--  1 root             root                           0 11月 30 16:53 vmstat
    -r--r--r--  1 root             root                           0 11月 30 16:53 zoneinfo
    
    

    1. /proc/cpuinfo

    在linux操作系统中,CPU的信息在启动的过程中被装载到虚拟目录/proc下的cpuinfo文件中,我们可以通过 cat /proc/cpuinfo 查看一下。

    该文件中存放了有关 cpu的相关信息(型号,缓存大小等)

    
    root@jimmy-vm:/proc# cat cpuinfo
    processor       : 0
    vendor_id       : GenuineIntel
    cpu family      : 6
    model           : 94
    model name      : Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz
    stepping        : 3
    microcode       : 0xc2
    cpu MHz         : 2712.002
    cache size      : 6144 KB
    physical id     : 0
    siblings        : 1
    core id         : 0
    cpu cores       : 1
    apicid          : 0
    initial apicid  : 0
    fpu             : yes
    fpu_exception   : yes
    cpuid level     : 22
    wp              : yes
    flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch epb invpcid_single kaiser fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap xsaveopt xsavec xgetbv1 dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
    bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
    bogomips        : 5424.00
    clflush size    : 64
    cache_alignment : 64
    address sizes   : 42 bits physical, 48 bits virtual
    power management:
    

    上面的各个参数的含义解释如下:

    属性 含义
    processor 逻辑处理器的id。
    vendor id CPU制造商
    cpu family CPU产品系列代号
    model CPU属于其系列中的哪一代的代号
    model name CPU属于的名字及其编号、标称主频
    stepping CPU属于制作更新版本
    cpu MHz CPU的实际使用主频
    cache size CPU二级缓存大小
    physical id 单个CPU的标号
    siblings 单个CPU逻辑物理核数
    core id 当前物理核在其所处CPU中的编号,这个编号不一定连续
    cpu cores 该逻辑核所处CPU的物理核数
    apicid 用来区分不同逻辑核的编号,系统中每个逻辑核的此编号必然不同,此编号不一定连续
    fpu 是否具有浮点运算单元(Floating Point Unit)
    fpu_exception 是否支持浮点计算异常
    cpuid level 执行cpuid指令前,eax寄存器中的值,根据不同的值cpuid指令会返回不同的内容
    wp 表明当前CPU是否在内核态支持对用户空间的写保护(Write Protection)
    flags 当前CPU支持的功能
    bogomips 在系统内核启动时粗略测算的CPU速度(Million Instructions Per Second)
    clflush size 每次刷新缓存的大小单位
    cache_alignment 缓存地址对齐单位
    address sizes 可访问地址空间位数
  • 相关阅读:
    Java实现三人年龄
    从session中获取当前用户的工具类
    全局Session-GlobalSession
    Request获取Session的两种方式
    跨域访问sessionid不一致问题
    获得HttpServletRequest 和HttpSession对象
    eclipse pom.xml 报错org.apache.maven.plugin.war.WarMojo的解决办法
    idea与eclipse项目相互导入的过程
    静态工具类中使用注解注入service实例
    解决静态utils里面注入mapper对象
  • 原文地址:https://www.cnblogs.com/Jimmy1988/p/10045541.html
Copyright © 2011-2022 走看看