Skip to content

Commit

Permalink
Speiciifed one function for specifying resource limits for both C/Cpp…
Browse files Browse the repository at this point in the history
… and Java execution files.
  • Loading branch information
shashankkumar committed Nov 23, 2011
1 parent 3956dcb commit 87f0eb1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions resources.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
void setResourceLimit(int resource, int softLimit, int hardLimit){
void SetResourceLimit(int resource, int softLimit, int hardLimit){
rlimit r;
r.rlim_cur = softLimit, r.rlim_max = hardLimit;
setrlimit(resource, &r);
}


void SetResourceLimitValues(int TimeLimit){
setResourceLimit(RLIMIT_CPU,TimeLimit, TimeLimit); // Time Limit specified by the problem setter
setResourceLimit(RLIMIT_CORE, 0, 0);
setResourceLimit(RLIMIT_FSIZE, 26214400, 26214400); // Max printing allowed to the tune of 256 MB
setResourceLimit(RLIMIT_STACK, 8192, 8192);
setResourceLimit(RLIMIT_NPROC, 0, 0);

SetResourceLimit(RLIMIT_CPU,TimeLimit, TimeLimit); // Time Limit specified by the problem setter
SetResourceLimit(RLIMIT_CORE, 0, 0);
SetResourceLimit(RLIMIT_FSIZE, 16777216, 16777216); // Max printing allowed to the tune of 16 MB
SetResourceLimit(RLIMIT_STACK, 8192, 8192);
SetResourceLimit(RLIMIT_NPROC, 0, 0);
}

/**
void setResourceLimitWrapper(int TimeLimit, int MemoryLimit){
setResourceLimit(RLIMIT_CPU,TimeLimit, TimeLimit); // Time Limit specified by the problem setter
setResourceLimit(RLIMIT_NICE,0, 0);
Expand Down Expand Up @@ -52,6 +53,7 @@ void Java_setResourceLimitWrapper(int TimeLimit, int MemoryLimit){
setResourceLimit(RLIMIT_STACK, 8192, 8192);
//setResourceLimit(RLIMIT_OFILE, 1, 1); // Dont know what it is??
}
*/
/*
getrlimit() and setrlimit() get and set resource limits respectively. Each resource has an associated soft and hard limit, as defined by the
Expand Down

0 comments on commit 87f0eb1

Please sign in to comment.