【Linux】函数long sysconf(int name)运行时查看配置信息

来源:互联网 发布:天津mac专柜 编辑:程序博客网 时间:2024/05/17 03:02

http://blog.csdn.net/pfanaya/article/details/7059761

[cpp] view plaincopy
  1. /* 
  2. NAME 
  3.        sysconf - Get configuration information at runtime 
  4.  
  5. SYNOPSIS 
  6.        #include <unistd.h> 
  7.  
  8.        long sysconf(int name); 
  9.  */  
  10. #include <stdio.h>  
  11. #include <unistd.h>  
  12.   
  13. int main(int argc, char *argv[])  
  14. {  
  15.     printf ("The pagesize: %ld\n", sysconf(_SC_PAGESIZE));  
  16.     printf ("The number of pages: %ld\n", sysconf(_SC_PHYS_PAGES));  
  17.     printf ("The number of available pages: %ld\n", sysconf(_SC_AVPHYS_PAGES));  
  18.     printf ("The number of processors: %ld\n", sysconf(_SC_NPROCESSORS_CONF));  
  19.     printf ("The number of processors online: %ld\n", sysconf(_SC_NPROCESSORS_ONLN));  
  20.     printf ("The memory size: %lld MB\n", (long long)sysconf(_SC_PAGESIZE) * (long long)sysconf(_SC_PHYS_PAGES) / (1024*1024) );  
  21.     printf ("The number of files max opened:: %ld\n", sysconf(_SC_OPEN_MAX));  
  22.     printf("The number of ticks per second: %ld\n", sysconf(_SC_CLK_TCK));  
  23.     printf ("The max length of host name: %ld\n", sysconf(_SC_HOST_NAME_MAX));  
  24.     printf ("The max length of login name: %ld\n", sysconf(_SC_LOGIN_NAME_MAX));  
  25.     return 0;  
  26. }  
  27. /* man sysconf */ 

0 0
原创粉丝点击