-
-
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.
Merge pull request #31 from daschuer/limits
check for rlimits on Linux
- Loading branch information
Showing
5 changed files
with
77 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,39 @@ | ||
#include "util/rlimit.h" | ||
|
||
#ifdef __LINUX__ | ||
|
||
extern "C" { | ||
#include <sys/time.h> | ||
#include <sys/resource.h> | ||
} | ||
|
||
// TODO(xxx) this is the result from a calculation inside PortAudio | ||
// We should query the value from PA or do the same calculations | ||
const rlim_t PA_RTPRIO = 82; // PA sets RtPrio = 82 | ||
|
||
// 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() >= PA_RTPRIO); // 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_ |