版本

sysinfo()首次出现在Linux 0.98.pl6中。

返回值

成功时,sysinfo()返回零。发生错误时,将返回-1,并设置errno以指示错误原因。

名称

sysinfo-返回系统信息

备注

该系统调用提供的所有信息也可以通过/ proc / meminfo和/ proc / loadavg获得。

语法

#包括

int sysinfo(struct sysinfo * info);

错误说明

EFAULT
信息不是有效的地址。

出版信息

这个页面是Linux手册页项目5.08版的一部分。有关项目的说明、有关报告错误的信息以及此页面的最新版本,请访问https://www.kernel.org/doc/man-pages/

遵循规范

此功能特定于Linux,不应在打算移植的程序中使用。

另外参见

proc(5)

SYSINFO - Linux手册页

Linux程序员手册 第2部分
更新日期: 2017-09-15

说明

sysinfo()返回有关内存和交换使用情况以及平均负载的某些统计信息。

在Linux 2.3.16之前,sysinfo()返回以下结构的信息:

struct sysinfo {
    long uptime;             /* Seconds since boot */
    unsigned long loads[3];  /* 1, 5, and 15 minute load averages */
    unsigned long totalram;  /* Total usable main memory size */
    unsigned long freeram;   /* Available memory size */
    unsigned long sharedram; /* Amount of shared memory */
    unsigned long bufferram; /* Memory used by buffers */
    unsigned long totalswap; /* Total swap space size */
    unsigned long freeswap;  /* Swap space still available */
    unsigned short procs;    /* Number of current processes */
    char _f[22];             /* Pads structure to 64 bytes */
};

在上述结构中,内存和交换字段的大小以字节为单位。

从Linux 2.3.23(i386)和Linux 2.3.48(所有体系结构)开始,结构为:

struct sysinfo {
    long uptime;             /* Seconds since boot */
    unsigned long loads[3];  /* 1, 5, and 15 minute load averages */
    unsigned long totalram;  /* Total usable main memory size */
    unsigned long freeram;   /* Available memory size */
    unsigned long sharedram; /* Amount of shared memory */
    unsigned long bufferram; /* Memory used by buffers */
    unsigned long totalswap; /* Total swap space size */
    unsigned long freeswap;  /* Swap space still available */
    unsigned short procs;    /* Number of current processes */
    unsigned long totalhigh; /* Total high memory size */
    unsigned long freehigh;  /* Available high memory size */
    unsigned int mem_unit;   /* Memory unit size in bytes */
    char _f[20-2*sizeof(long)-sizeof(int)];
                             /* Padding to 64 bytes */
};

在上述结构中,内存和交换字段的大小以mem_unit字节的倍数给出。

日期:2019-08-20 17:59:33 来源:oir作者:oir