add the ability to set the priority of the render process as commandline argument
This commit is contained in:
committed by
Laurent Clouet
parent
2f00d7816d
commit
d8aa315699
@@ -161,7 +161,12 @@ public class FreeBSD extends OS {
|
||||
}
|
||||
if (this.hasNiceBinary.booleanValue()) {
|
||||
// launch the process in lowest priority
|
||||
actual_command.add(0, "19");
|
||||
if (env_overight != null) {
|
||||
actual_command.add(0, env_overight.get("PRIORITY"));
|
||||
}
|
||||
else {
|
||||
actual_command.add(0, "19");
|
||||
}
|
||||
actual_command.add(0, "-n");
|
||||
actual_command.add(0, NICE_BINARY_PATH);
|
||||
}
|
||||
|
||||
@@ -144,7 +144,12 @@ public class Linux extends OS {
|
||||
}
|
||||
if (this.hasNiceBinary.booleanValue()) {
|
||||
// launch the process in lowest priority
|
||||
actual_command.add(0, "19");
|
||||
if (env_overight != null) {
|
||||
actual_command.add(0, env_overight.get("PRIORITY"));
|
||||
}
|
||||
else {
|
||||
actual_command.add(0, "19");
|
||||
}
|
||||
actual_command.add(0, "-n");
|
||||
actual_command.add(0, NICE_BINARY_PATH);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,12 @@ public class Mac extends OS {
|
||||
}
|
||||
if (this.hasNiceBinary.booleanValue()) {
|
||||
// launch the process in lowest priority
|
||||
actual_command.add(0, "19");
|
||||
if (env != null) {
|
||||
actual_command.add(0, env.get("PRIORITY"));
|
||||
}
|
||||
else {
|
||||
actual_command.add(0, "19");
|
||||
}
|
||||
actual_command.add(0, "-n");
|
||||
actual_command.add(0, NICE_BINARY_PATH);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,13 @@ public class Windows extends OS {
|
||||
}
|
||||
Process p = builder.start();
|
||||
WinProcess wproc = new WinProcess(p);
|
||||
wproc.setPriority(WinProcess.PRIORITY_BELOW_NORMAL);
|
||||
if (env != null) {
|
||||
String priority = env.get("PRIORITY");
|
||||
wproc.setPriority(getPriorityClass(Integer.parseInt(priority)));
|
||||
}
|
||||
else {
|
||||
wproc.setPriority(WinProcess.PRIORITY_BELOW_NORMAL);
|
||||
}
|
||||
if (env != null) {
|
||||
String cores = env.get("CORES");
|
||||
wproc.setAffinity(Integer.parseInt(cores));
|
||||
@@ -140,6 +146,65 @@ public class Windows extends OS {
|
||||
return p;
|
||||
}
|
||||
|
||||
int getPriorityClass(int priority) {
|
||||
int process_class = WinProcess.PRIORITY_IDLE;
|
||||
switch (priority) {
|
||||
case 19:
|
||||
case 18:
|
||||
case 17:
|
||||
case 16:
|
||||
case 15:
|
||||
process_class = WinProcess.PRIORITY_IDLE;
|
||||
break;
|
||||
|
||||
case 14:
|
||||
case 13:
|
||||
case 12:
|
||||
case 11:
|
||||
case 10:
|
||||
case 9:
|
||||
case 8:
|
||||
case 7:
|
||||
case 6:
|
||||
case 5:
|
||||
process_class = WinProcess.PRIORITY_BELOW_NORMAL;
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
case 2:
|
||||
case 1:
|
||||
case 0:
|
||||
case -1:
|
||||
case -2:
|
||||
case -3:
|
||||
process_class = WinProcess.PRIORITY_NORMAL;
|
||||
break;
|
||||
case -4:
|
||||
case -5:
|
||||
case -6:
|
||||
case -7:
|
||||
case -8:
|
||||
case -9:
|
||||
process_class = WinProcess.PRIORITY_ABOVE_NORMAL;
|
||||
break;
|
||||
case -10:
|
||||
case -11:
|
||||
case -12:
|
||||
case -13:
|
||||
case -14:
|
||||
process_class = WinProcess.PRIORITY_HIGH;
|
||||
break;
|
||||
case -15:
|
||||
case -16:
|
||||
case -17:
|
||||
case -18:
|
||||
case -19:
|
||||
process_class = WinProcess.PRIORITY_REALTIME;
|
||||
break;
|
||||
}
|
||||
return process_class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean kill(Process process) {
|
||||
if (process != null) {
|
||||
|
||||
Reference in New Issue
Block a user