cis-452-lab-7/dynamic-queries.c

42 lines
1.1 KiB
C

#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <unistd.h>
#include <limits.h>
int main()
{
// Struct for getrlimit()
struct rlimit rlim;
// For calculating clock resolution
long ticks = 0L;
// Page size
printf("Page size (bytes): %ld\n", sysconf(_SC_PAGESIZE));
// Physical pages
printf("Number of physical pages: %ld\n", sysconf(_SC_PHYS_PAGES));
// # of processes per user
printf("Max # of processes per user: %ld\n", sysconf(_SC_CHILD_MAX));
// File size
getrlimit(RLIMIT_FSIZE, &rlim);
printf("Max file size (bytes) | soft limit: %ld\n", rlim.rlim_cur);
printf("Max file size (bytes) | hard limit: %ld\n", rlim.rlim_max);
// Number of open files
getrlimit(RLIMIT_NOFILE, &rlim);
printf("Number of open files | soft limit: %ld\n", rlim.rlim_cur);
printf("Number of open files | hard limit: %ld\n", rlim.rlim_max);
// Getting ticks per second
ticks = sysconf(_SC_CLK_TCK);
// Clock resolution
printf("Clock resolution (ms): %ld\n", 1000 / ticks);
return 0;
}