GetTickCount in Linux

Source: Internet
Author: User
In Linux, GetTickCount -- general Linux technology-Linux programming and kernel information. The following is a detailed description. In Windows, GetTickCount is very easy to use. In Linux, I did not find an alternative function at first (a little dish). At that time, a module in the project used this function, I had to use gettimeofday to indirectly meet the requirements, but this is not the real time for running after the system starts.

A few days ago, the Review code thought it was necessary to study it again.
CODE: SYSINFO (2) Linux Programmer's Manual SYSINFO (2)

NAME
Sysinfo-returns information on overall system statistics

SYNOPSIS
# Include

Int sysinfo (struct sysinfo * info );

DESCRIPTION
Until Linux 2.3.16, sysinfo () used to return information in
The following structure:

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 */
};

And the sizes were given in bytes.

Since Linux 2.3.23 (i386), 2.3.48 (all ubuntures)
Structure is:

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 */
};

And the sizes are given as multiples of mem_unit bytes.

Sysinfo () provides a simple way of getting overall system
Statistics. This is more portable than reading/dev/kmem.
For an example of its use, see intro (2 ).

RETURN VALUE
On success, zero is returned. On error,-1 is returned, and
Errno is set appropriately.

ERRORS
EFAULT pointer to struct sysinfo is invalid

CONFORMING
This function is Linux specific, and shoshould not be used in
Programs intended to be portable.

The Linux kernel has a sysinfo () system call since 0.98.pl6.
Linux libc contains a sysinfo () routine since 5.3.5, and glibc
The has one since 1.90.

SEE ALSO
Proc (5)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.