标签:div efi sof getrlimit 文件 res blog name nba
#include <stdio.h> #include <sys/time.h> #include <sys/resource.h> int main(int argc, char *argv[]) { struct rlimit nofile_rlmt; if (getrlimit(RLIMIT_NOFILE, &nofile_rlmt) != -1) { printf("获取进程最大能打开的文件描写叙述符个数信息:\n" "rlim_cur(Soft limit):%d" "\nrlim_max(Hard limit (ceiling for rlim_cur)): %d\n", nofile_rlmt.rlim_cur, nofile_rlmt.rlim_max); } }getrlimit与setlimit函数具体解释能够參照:
http://www.cnblogs.com/niocai/archive/2012/04/01/2428128.html
#include <stdio.h> #include <stdlib.h> #include <unistd.h> //sysconf #define ONE_MB (1024 * 1024) int main(int argc, char **argv[]) { long num_cpu = sysconf(_SC_NPROCESSORS_ONLN); printf("CUP的个数:%ld\n", num_cpu); long page_size = sysconf(_SC_PAGESIZE); printf("系统页面的大小:%ld K\n", page_size); long num_pages = sysconf(_SC_PHYS_PAGES); printf("系统中物理页面个数:%ld 个\n", num_pages); long free_pages = sysconf(_SC_AVPHYS_PAGES); printf("系统中可用的页面个数:%ld 个\n", free_pages); long long mem = (long long)((long long)num_pages * (long long)page_size); mem /= ONE_MB; long long free_mem = (long long)((long long)free_pages * (long long)page_size); free_mem /= ONE_MB; printf("总共同拥有 %lld MB的物理内存,空暇的物理内存有 %lld MB\n", mem, free_mem); long open_max = sysconf(_SC_OPEN_MAX); printf("每一个进程最大打开的文件个数:%ld\n", open_max); return 0; }sysconf、pathconf、fpathconf函数具体解释參照:
http://xingyunbaijunwei.blog.163.com/blog/static/7653806720119122344450/
标签:div efi sof getrlimit 文件 res blog name nba
原文地址:http://www.cnblogs.com/wzjhoutai/p/6711116.html