Skip to content
This repository
Browse code

Currently specifying one function for resource limit of source codes

  • Loading branch information...
commit f79b7c3ea5fdcff5437ebd2609dddc4b47153dc3 1 parent 16ba810
Shashank Kumar authored

Showing 1 changed file with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. +11 2 resources.h
13 resources.h
... ... @@ -1,9 +1,18 @@
1   -void setResourceLimit(int resource, int softLimit, int hardLimit){
  1 +void SetResourceLimit(int resource, int softLimit, int hardLimit){
2 2 rlimit r;
3 3 r.rlim_cur = softLimit, r.rlim_max = hardLimit;
4 4 setrlimit(resource, &r);
5 5 }
6 6
  7 +void SetResourceLimitValues(int TimeLimit){
  8 + setResourceLimit(RLIMIT_CPU,TimeLimit, TimeLimit); // Time Limit specified by the problem setter
  9 + setResourceLimit(RLIMIT_CORE, 0, 0);
  10 + setResourceLimit(RLIMIT_FSIZE, 26214400, 26214400); // Max printing allowed to the tune of 256 MB
  11 + setResourceLimit(RLIMIT_STACK, 8192, 8192);
  12 + setResourceLimit(RLIMIT_NPROC, 0, 0);
  13 +
  14 +}
  15 +/*
7 16 void setResourceLimitWrapper(int TimeLimit, int MemoryLimit){
8 17 setResourceLimit(RLIMIT_CPU,TimeLimit, TimeLimit); // Time Limit specified by the problem setter
9 18 setResourceLimit(RLIMIT_NICE,0, 0);
@@ -43,7 +52,7 @@ void Java_setResourceLimitWrapper(int TimeLimit, int MemoryLimit){
43 52 setResourceLimit(RLIMIT_STACK, 8192, 8192);
44 53 //setResourceLimit(RLIMIT_OFILE, 1, 1); // Dont know what it is??
45 54 }
46   -
  55 +*/
47 56 /*
48 57
49 58 getrlimit() and setrlimit() get and set resource limits respectively. Each resource has an associated soft and hard limit, as defined by the

0 comments on commit f79b7c3

Please sign in to comment.
Something went wrong with that request. Please try again.