0

I know that there is sysinfo structure under <sys/sysinfo.h> header file which stores the information.

But i wanted to know, how does Linux keep this information?, how does it initialize the structure?, When is it created and how is it stored?, How is it updated?, Can we customize the structure?

Is there are a file in which keep this information!?. Is there a alternate way to get system status information? can we bypass this and can directly get the status from the hardware.

(Attach resource if possible)

4

1 回答 1

1

The information returned by sysinfo() is collected on demand from various sources within the kernel. There isn't any one place it all comes from.

The structure is not practical to modify, as it is part of a shared kernel/userspace interface. Generally speaking, if you want to expose additional data to userspace, it should be published as a /proc node.

All of the information returned by sysinfo() is available from other sources within procfs:

  • info->uptime: /proc/uptime
  • info->loads: /proc/loadavg
  • info->totalram, etc: /proc/meminfo
  • info->procs: /proc itself (count the numbered subdirectories!)
于 2018-02-23T17:49:59.313 回答