|
|
@ -32,7 +32,6 @@ get_time()
|
|
|
|
return (Tp.tv_sec * 1000000 + Tp.tv_usec);
|
|
|
|
return (Tp.tv_sec * 1000000 + Tp.tv_usec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
static void
|
|
|
|
usage(char *cmd)
|
|
|
|
usage(char *cmd)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -40,6 +39,30 @@ usage(char *cmd)
|
|
|
|
debuglog("%s <modules_file>\n", cmd);
|
|
|
|
debuglog("%s <modules_file>\n", cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Sets the process data segment (RLIMIT_DATA) and # file descriptors
|
|
|
|
|
|
|
|
// (RLIMIT_NOFILE) soft limit to its hard limit (see man getrlimit)
|
|
|
|
|
|
|
|
void set_resource_limits_to_max(){
|
|
|
|
|
|
|
|
struct rlimit resource_limit;
|
|
|
|
|
|
|
|
if (getrlimit(RLIMIT_DATA, &resource_limit) < 0) {
|
|
|
|
|
|
|
|
perror("getrlimit RLIMIT_DATA");
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
resource_limit.rlim_cur = resource_limit.rlim_max;
|
|
|
|
|
|
|
|
if (setrlimit(RLIMIT_DATA, &resource_limit) < 0) {
|
|
|
|
|
|
|
|
perror("setrlimit RLIMIT_DATA");
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (getrlimit(RLIMIT_NOFILE, &resource_limit) < 0) {
|
|
|
|
|
|
|
|
perror("getrlimit RLIMIT_NOFILE");
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
resource_limit.rlim_cur = resource_limit.rlim_max;
|
|
|
|
|
|
|
|
if (setrlimit(RLIMIT_NOFILE, &resource_limit) < 0) {
|
|
|
|
|
|
|
|
perror("setrlimit RLIMIT_NOFILE");
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -57,27 +80,7 @@ main(int argc, char **argv)
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Sets the process data segment (RLIMIT_DATA) and # file descriptors
|
|
|
|
set_resource_limits_to_max();
|
|
|
|
// (RLIMIT_NOFILE) soft limit to its hard limit (see man getrlimit)
|
|
|
|
|
|
|
|
struct rlimit r;
|
|
|
|
|
|
|
|
if (getrlimit(RLIMIT_DATA, &r) < 0) {
|
|
|
|
|
|
|
|
perror("getrlimit RLIMIT_DATA");
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
r.rlim_cur = r.rlim_max;
|
|
|
|
|
|
|
|
if (setrlimit(RLIMIT_DATA, &r) < 0) {
|
|
|
|
|
|
|
|
perror("setrlimit RLIMIT_DATA");
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (getrlimit(RLIMIT_NOFILE, &r) < 0) {
|
|
|
|
|
|
|
|
perror("getrlimit RLIMIT_NOFILE");
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
r.rlim_cur = r.rlim_max;
|
|
|
|
|
|
|
|
if (setrlimit(RLIMIT_NOFILE, &r) < 0) {
|
|
|
|
|
|
|
|
perror("setrlimit RLIMIT_NOFILE");
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Find the number of processors currently online
|
|
|
|
// Find the number of processors currently online
|
|
|
|
ncores = sysconf(_SC_NPROCESSORS_ONLN);
|
|
|
|
ncores = sysconf(_SC_NPROCESSORS_ONLN);
|
|
|
|