add the ability to set the priority of the render process as commandline argument

This commit is contained in:
Rolf Aretz Lap
2017-01-05 09:58:27 +01:00
committed by Laurent Clouet
parent 2f00d7816d
commit d8aa315699
7 changed files with 105 additions and 4 deletions

View File

@@ -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) {