-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "rlimit.h" | ||
|
||
#ifdef __LINUX__ | ||
|
||
extern "C" { | ||
#include <sys/time.h> | ||
#include <sys/resource.h> | ||
} | ||
|
||
// static | ||
unsigned int RLimit::getCurRtPrio() { | ||
struct rlimit limits; | ||
if(getrlimit(RLIMIT_RTPRIO, &limits)) { | ||
// Error | ||
return 100; | ||
} | ||
return limits.rlim_cur; | ||
} | ||
|
||
// static | ||
unsigned int RLimit::getMaxRtPrio() { | ||
struct rlimit limits; | ||
if(getrlimit(RLIMIT_RTPRIO, &limits)) { | ||
// Error | ||
return 0; | ||
} | ||
return limits.rlim_max; | ||
} | ||
|
||
// static | ||
bool RLimit::isRtPrioAllowed() { | ||
return (getCurRtPrio() >= 82); // PA sets RtPrio = 82 | ||
} | ||
|
||
#endif // __LINUX__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef RLIMIT_H | ||
#define RLIMIT_H | ||
|
||
#ifdef __LINUX__ | ||
|
||
class RLimit { | ||
public: | ||
static unsigned int getCurRtPrio(); | ||
static unsigned int getMaxRtPrio(); | ||
static bool isRtPrioAllowed(); | ||
}; | ||
|
||
#endif // __LINUX__ | ||
#endif // RLIMIT_H_ |