码迷,mamicode.com
首页 > 系统相关 > 详细

Linux函数整理 sysconf

时间:2016-06-30 12:17:51      阅读:392      评论:0      收藏:0      [点我收藏+]

标签:

sysconf这个函数用来获取系统执行的配置信息。例如页大小、最大页数、cpu个数、打开句柄的最大个数等。

 

#include <stdio.h>
#include <unistd.h>

#define ONE_MB (1024 * 1024)

int main()
{
  //处理器数目 printf(
"The number of processors configured is :%ld\n", sysconf(_SC_NPROCESSORS_CONF)); printf("The number of processors currently online (available) is :%ld\n", sysconf(_SC_NPROCESSORS_ONLN));
  //页大小 printf (
"The pagesize: %ld\n", sysconf(_SC_PAGESIZE));
  //页数目 printf (
"The number of pages: %ld\n", sysconf(_SC_PHYS_PAGES)); printf ("The number of available pages: %ld\n", sysconf(_SC_AVPHYS_PAGES));
  //内存 printf (
"The memory size: %lld MB\n", (long long)sysconf(_SC_PAGESIZE) * (long long)sysconf(_SC_PHYS_PAGES) / ONE_MB );
  //最大打开文件数 printf (
"The number of files max opened:: %ld\n", sysconf(_SC_OPEN_MAX));
  //时钟 printf(
"The number of ticks per second: %ld\n", sysconf(_SC_CLK_TCK)); printf ("The max length of host name: %ld\n", sysconf(_SC_HOST_NAME_MAX)); printf ("The max length of login name: %ld\n", sysconf(_SC_LOGIN_NAME_MAX)); return 0; }

 

Linux函数整理 sysconf

标签:

原文地址:http://www.cnblogs.com/how-are-you/p/5629425.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!