【Linux】函数long sysconf(int name)运行时查看配置信息
/*NAMEsysconf - Get configuration information at runtimeSYNOPSIS#includelong sysconf(int name);*/#include#includeint main(int argc, char *argv[]){printf ("Th
·
/*
NAME
sysconf - Get configuration information at runtime
SYNOPSIS
#include <unistd.h>
long sysconf(int name);
*/
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
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 number of processors: %ld\n", sysconf(_SC_NPROCESSORS_CONF));
printf ("The number of processors online: %ld\n", sysconf(_SC_NPROCESSORS_ONLN));
printf ("The memory size: %lld MB\n", (long long)sysconf(_SC_PAGESIZE) * (long long)sysconf(_SC_PHYS_PAGES) / (1024*1024) );
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;
}
/* man sysconf */
更多推荐
已为社区贡献4条内容
所有评论(0)