sysinfo() - Unix,Linux系統呼叫 - 技術教學
Tutorials Point


  Unix初學者指南
  Unix Shell程式設計
  高階Unix
  Unix有用參考
  Unix有用資源
  精選閱讀

版權所有 © 2014 tutorialspoint



  首頁     參考     討論論壇     關於TP  

sysinfo() - Unix,Linux系統呼叫


previous next AddThis Social Bookmark Button

廣告

名稱

sysinfo - 返回有關整體系統統計資訊的資訊

概要

#include <sys/sysinfo.h>

int sysinfo(struct sysinfo *info);

描述

在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) , 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 for libc5 */
};

大小以mem_unit位元組的倍數給出。

sysinfo() 提供了一種獲取整體系統統計資訊的簡單方法。這比讀取/dev/kmem更具可移植性。有關其用法的示例,請參見intro(2)。

返回值

成功時,返回零。失敗時,返回 -1,並適當地設定errno

錯誤

標籤描述
EFAULT 指向struct sysinfo的指標無效

符合標準

此函式是Linux特有的,不應在旨在可移植的程式中使用。

Linux核心自0.98.pl6以來就具有sysinfo()系統呼叫。 Linux libc自5.3.5以來包含sysinfo()例程,glibc自1.90以來就包含一個。

參見



previous next Printer Friendly

廣告


  

廣告



廣告