Merge branch 'master' of ssh://isaac.ssl.berkeley.edu/boinc-v2

This commit is contained in:
Rom Walton 2014-10-13 15:39:51 -04:00
commit 6eb9f2d298
5 changed files with 47 additions and 7 deletions

View File

@ -73,6 +73,20 @@
#define MODE_QUIT 6
#define NGRAPHICS_MSGS 7
// process priorities
//
#define PROCESS_PRIORITY_UNSPECIFIED 0
#define PROCESS_PRIORITY_LOWEST 1
// win: IDLE; unix: 19
#define PROCESS_PRIORITY_LOW 2
// win: BELOW_NORMAL; unix: 10
#define PROCESS_PRIORITY_NORMAL 3
// win: NORMAL; unix: 0
#define PROCESS_PRIORITY_HIGH 4
// win: ABOVE_NORMAL; unix: -10
#define PROCESS_PRIORITY_HIGHEST 5
// win: HIGH; unix: -16
// priorities for client messages
//
#define MSG_INFO 1

View File

@ -39,6 +39,7 @@
#endif
#endif
#include "common_defs.h"
#include "procinfo.h"
#include "str_util.h"
#include "util.h"
@ -249,3 +250,27 @@ void suspend_or_resume_process(int pid, bool resume) {
::kill(pid, resume?SIGCONT:SIGSTOP);
#endif
}
// return OS-specific value associated with priority code
//
int process_priority_value(int priority) {
#ifdef _WIN32
switch (priority) {
case PROCESS_PRIORITY_LOWEST: return IDLE_PRIORITY_CLASS;
case PROCESS_PRIORITY_LOW: return BELOW_NORMAL_PRIORITY_CLASS;
case PROCESS_PRIORITY_NORMAL: return NORMAL_PRIORITY_CLASS;
case PROCESS_PRIORITY_HIGH: return ABOVE_NORMAL_PRIORITY_CLASS;
case PROCESS_PRIORITY_HIGHEST: return HIGH_PRIORITY_CLASS;
}
return 0;
#else
switch (priority) {
case PROCESS_PRIORITY_LOWEST: return 19;
case PROCESS_PRIORITY_LOW: return 10;
case PROCESS_PRIORITY_NORMAL: return 0;
case PROCESS_PRIORITY_HIGH: return -10;
case PROCESS_PRIORITY_HIGHEST: return -16;
}
return 0;
#endif
}

View File

@ -37,4 +37,6 @@ extern void kill_descendants(int child_pid=0);
extern void suspend_or_resume_descendants(bool resume);
extern void suspend_or_resume_process(int pid, bool resume);
extern int process_priority_value(int);
#endif

View File

@ -125,7 +125,7 @@ struct TASK {
bool append_cmdline_args;
bool multi_process;
double time_limit;
bool no_priority_change;
int priority;
// dynamic stuff follows
double current_cpu_time;
@ -381,7 +381,7 @@ int TASK::parse(XML_PARSER& xp) {
multi_process = false;
append_cmdline_args = false;
time_limit = 0;
no_priority_change = false;
priority = PROCESS_PRIORITY_LOWEST;
while (!xp.get_tag()) {
if (!xp.is_tag) {
@ -419,7 +419,7 @@ int TASK::parse(XML_PARSER& xp) {
else if (xp.parse_bool("multi_process", multi_process)) continue;
else if (xp.parse_bool("append_cmdline_args", append_cmdline_args)) continue;
else if (xp.parse_double("time_limit", time_limit)) continue;
else if (xp.parse_bool("no_priority_change", no_priority_change)) continue;
else if (xp.parse_int("priority", priority)) continue;
}
return ERR_XML_PARSE;
}
@ -697,7 +697,7 @@ int TASK::run(int argct, char** argvt) {
NULL,
NULL,
TRUE, // bInheritHandles
CREATE_NO_WINDOW|(no_priority_change?0:IDLE_PRIORITY_CLASS),
CREATE_NO_WINDOW|process_priority_value(priority),
(LPVOID) env_vars,
exec_dir.empty()?NULL:exec_dir.c_str(),
&startup_info,
@ -772,9 +772,7 @@ int TASK::run(int argct, char** argvt) {
argv[0] = app_path;
strlcpy(arglist, command_line.c_str(), sizeof(arglist));
parse_command_line(arglist, argv+1);
if (!no_priority_change) {
setpriority(PRIO_PROCESS, 0, PROCESS_IDLE_PRIORITY);
}
setpriority(PRIO_PROCESS, 0, process_priority_value(priority));
if (!exec_dir.empty()) {
retval = chdir(exec_dir.c_str());
if (!retval) {

View File

@ -90,6 +90,7 @@
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">wrapper_26011_windows_x86_64</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">wrapper_26011_windows_intelx86</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">wrapper_6.1_windows_x86_64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>