@@ -2,7 +2,7 @@
|
||||
* Copyright (C) 2010-2015 Laurent CLOUET
|
||||
* Author Laurent CLOUET <laurent.clouet@nopnop.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; version 2
|
||||
* of the License.
|
||||
@@ -42,13 +42,11 @@ public class FreeBSD extends OS {
|
||||
return "freebsd";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRenderBinaryPath() {
|
||||
@Override public String getRenderBinaryPath() {
|
||||
return "rend.exe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPU getCPU() {
|
||||
@Override public CPU getCPU() {
|
||||
CPU ret = new CPU();
|
||||
try {
|
||||
Runtime r = Runtime.getRuntime();
|
||||
@@ -110,8 +108,7 @@ public class FreeBSD extends OS {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMemory() {
|
||||
@Override public long getMemory() {
|
||||
try {
|
||||
Runtime r = Runtime.getRuntime();
|
||||
Process p = r.exec("sysctl -n hw.usermem");
|
||||
@@ -133,18 +130,15 @@ public class FreeBSD extends OS {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeMemory() {
|
||||
@Override public long getFreeMemory() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCUDALib() {
|
||||
@Override public String getCUDALib() {
|
||||
return "cuda";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Process exec(List<String> command, Map<String, String> env_overight) throws IOException {
|
||||
@Override public Process exec(List<String> command, Map<String, String> env_overight) throws IOException {
|
||||
// the renderer have a lib directory so add to the LD_LIBRARY_PATH
|
||||
// (even if we are not sure that it is the renderer who is launch
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright (C) 2010-2014 Laurent CLOUET
|
||||
* Author Laurent CLOUET <laurent.clouet@nopnop.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; version 2
|
||||
* of the License.
|
||||
@@ -43,13 +43,11 @@ public class Linux extends OS {
|
||||
return "linux";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRenderBinaryPath() {
|
||||
@Override public String getRenderBinaryPath() {
|
||||
return "rend.exe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPU getCPU() {
|
||||
@Override public CPU getCPU() {
|
||||
CPU ret = new CPU();
|
||||
try {
|
||||
String filePath = "/proc/cpuinfo";
|
||||
@@ -89,8 +87,7 @@ public class Linux extends OS {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMemory() {
|
||||
@Override public long getMemory() {
|
||||
try {
|
||||
String filePath = "/proc/meminfo";
|
||||
Scanner scanner = new Scanner(new File(filePath));
|
||||
@@ -118,8 +115,7 @@ public class Linux extends OS {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeMemory() {
|
||||
@Override public long getFreeMemory() {
|
||||
try {
|
||||
String filePath = "/proc/meminfo";
|
||||
Scanner scanner = new Scanner(new File(filePath));
|
||||
@@ -138,7 +134,8 @@ public class Linux extends OS {
|
||||
scanner.close();
|
||||
}
|
||||
catch (java.lang.NoClassDefFoundError e) {
|
||||
System.err.println("OS::Linux::getFreeMemory error " + e + " mostly because Scanner class was introducted by Java 5 and you are running a lower version");
|
||||
System.err.println(
|
||||
"OS::Linux::getFreeMemory error " + e + " mostly because Scanner class was introducted by Java 5 and you are running a lower version");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -147,13 +144,11 @@ public class Linux extends OS {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCUDALib() {
|
||||
@Override public String getCUDALib() {
|
||||
return "cuda";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Process exec(List<String> command, Map<String, String> env_overight) throws IOException {
|
||||
@Override public Process exec(List<String> command, Map<String, String> env_overight) throws IOException {
|
||||
Map<String, String> new_env = new HashMap<String, String>();
|
||||
new_env.putAll(java.lang.System.getenv()); // clone the env
|
||||
|
||||
@@ -201,13 +196,12 @@ public class Linux extends OS {
|
||||
return builder.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSupportHighPriority() {
|
||||
@Override public boolean getSupportHighPriority() {
|
||||
// only the root user can create process with high (negative nice) value
|
||||
String logname = System.getenv("LOGNAME");
|
||||
String user = System.getenv("USER");
|
||||
|
||||
if ((logname != null && logname.equals("root")) || (user != null && user.equals("root"))) {
|
||||
if ((logname != null && logname.equals("root")) || (user != null && user.equals("root"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright (C) 2010-2014 Laurent CLOUET
|
||||
* Author Laurent CLOUET <laurent.clouet@nopnop.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; version 2
|
||||
* of the License.
|
||||
@@ -41,13 +41,11 @@ public class Mac extends OS {
|
||||
return "mac";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRenderBinaryPath() {
|
||||
@Override public String getRenderBinaryPath() {
|
||||
return "Blender" + File.separator + "blender.app" + File.separator + "Contents" + File.separator + "MacOS" + File.separator + "blender";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPU getCPU() {
|
||||
@Override public CPU getCPU() {
|
||||
CPU ret = new CPU();
|
||||
|
||||
String command = "sysctl machdep.cpu.family machdep.cpu.brand_string";
|
||||
@@ -97,8 +95,7 @@ public class Mac extends OS {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMemory() {
|
||||
@Override public long getMemory() {
|
||||
String command = "sysctl hw.memsize";
|
||||
|
||||
Process p = null;
|
||||
@@ -140,13 +137,11 @@ public class Mac extends OS {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeMemory() {
|
||||
@Override public long getFreeMemory() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Process exec(List<String> command, Map<String, String> env) throws IOException {
|
||||
@Override public Process exec(List<String> command, Map<String, String> env) throws IOException {
|
||||
List<String> actual_command = command;
|
||||
if (this.hasNiceBinary == null) {
|
||||
this.checkNiceAvailability();
|
||||
@@ -173,8 +168,7 @@ public class Mac extends OS {
|
||||
return builder.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCUDALib() {
|
||||
@Override public String getCUDALib() {
|
||||
return "/usr/local/cuda/lib/libcuda.dylib";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright (C) 2010-2014 Laurent CLOUET
|
||||
* Author Laurent CLOUET <laurent.clouet@nopnop.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; version 2
|
||||
* of the License.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright (C) 2010-2014 Laurent CLOUET
|
||||
* Author Laurent CLOUET <laurent.clouet@nopnop.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; version 2
|
||||
* of the License.
|
||||
@@ -37,13 +37,11 @@ public class Windows extends OS {
|
||||
return "windows";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRenderBinaryPath() {
|
||||
@Override public String getRenderBinaryPath() {
|
||||
return "rend.exe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPU getCPU() {
|
||||
@Override public CPU getCPU() {
|
||||
CPU ret = new CPU();
|
||||
try {
|
||||
String[] identifier = java.lang.System.getenv("PROCESSOR_IDENTIFIER").split(" ");
|
||||
@@ -88,8 +86,7 @@ public class Windows extends OS {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMemory() {
|
||||
@Override public long getMemory() {
|
||||
try {
|
||||
MEMORYSTATUSEX _memory = new MEMORYSTATUSEX();
|
||||
if (Kernel32.INSTANCE.GlobalMemoryStatusEx(_memory)) {
|
||||
@@ -102,8 +99,7 @@ public class Windows extends OS {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeMemory() {
|
||||
@Override public long getFreeMemory() {
|
||||
try {
|
||||
MEMORYSTATUSEX _memory = new MEMORYSTATUSEX();
|
||||
if (Kernel32.INSTANCE.GlobalMemoryStatusEx(_memory)) {
|
||||
@@ -112,18 +108,16 @@ public class Windows extends OS {
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCUDALib() {
|
||||
@Override public String getCUDALib() {
|
||||
return "nvcuda";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Process exec(List<String> command, Map<String, String> env) throws IOException {
|
||||
@Override public Process exec(List<String> command, Map<String, String> env) throws IOException {
|
||||
// disable a popup because the renderer might crash (seg fault)
|
||||
Kernel32Lib kernel32lib = null;
|
||||
try {
|
||||
@@ -216,8 +210,7 @@ public class Windows extends OS {
|
||||
return process_class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean kill(Process process) {
|
||||
@Override public boolean kill(Process process) {
|
||||
if (process != null) {
|
||||
WinProcess wproc = new WinProcess(process);
|
||||
wproc.kill();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* This file was originally taken from JNA project (https://github.com/twall/jna)
|
||||
* filename: contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
@@ -61,7 +61,8 @@ public interface Kernel32Lib extends Library {
|
||||
/**
|
||||
* Includes all processes and threads in the system, plus the heaps and modules of the process specified in th32ProcessID.
|
||||
*/
|
||||
WinDef.DWORD TH32CS_SNAPALL = new WinDef.DWORD((TH32CS_SNAPHEAPLIST.intValue() | TH32CS_SNAPPROCESS.intValue() | TH32CS_SNAPTHREAD.intValue() | TH32CS_SNAPMODULE.intValue()));
|
||||
WinDef.DWORD TH32CS_SNAPALL = new WinDef.DWORD(
|
||||
(TH32CS_SNAPHEAPLIST.intValue() | TH32CS_SNAPPROCESS.intValue() | TH32CS_SNAPTHREAD.intValue() | TH32CS_SNAPMODULE.intValue()));
|
||||
|
||||
/**
|
||||
* Indicates that the snapshot handle is to be inheritable.
|
||||
@@ -151,9 +152,10 @@ public interface Kernel32Lib extends Library {
|
||||
*/
|
||||
public char[] szExeFile = new char[WinDef.MAX_PATH];
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", "cntThreads", "th32ParentProcessID", "pcPriClassBase", "dwFlags", "szExeFile");
|
||||
@Override protected List<String> getFieldOrder() {
|
||||
return Arrays
|
||||
.asList("dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", "cntThreads", "th32ParentProcessID", "pcPriClassBase",
|
||||
"dwFlags", "szExeFile");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright (C) 2013 Laurent CLOUET
|
||||
* Author Laurent CLOUET <laurent.clouet@nopnop.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; version 2
|
||||
* of the License.
|
||||
@@ -84,13 +84,14 @@ public class WinProcess {
|
||||
|
||||
private static WinNT.HANDLE getHandleByPid(int pid_) throws IOException {
|
||||
WinNT.HANDLE handle = Kernel32.INSTANCE.OpenProcess(0x0400 | // PROCESS_QUERY_INFORMATION
|
||||
0x0800 | // PROCESS_SUSPEND_RESUME
|
||||
0x0001 | // PROCESS_TERMINATE
|
||||
0x0200 | // PROCESS_SET_INFORMATION
|
||||
0x00100000, // SYNCHRONIZE
|
||||
0x0800 | // PROCESS_SUSPEND_RESUME
|
||||
0x0001 | // PROCESS_TERMINATE
|
||||
0x0200 | // PROCESS_SET_INFORMATION
|
||||
0x00100000, // SYNCHRONIZE
|
||||
false, pid_);
|
||||
if (handle == null) {
|
||||
throw new IOException("OpenProcess failed: " + Kernel32Util.formatMessageFromLastErrorCode(Kernel32.INSTANCE.GetLastError()) + " (pid: " + pid_ + ")");
|
||||
throw new IOException(
|
||||
"OpenProcess failed: " + Kernel32Util.formatMessageFromLastErrorCode(Kernel32.INSTANCE.GetLastError()) + " (pid: " + pid_ + ")");
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
@@ -130,8 +131,7 @@ public class WinProcess {
|
||||
this.pid = pid_;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
@Override protected void finalize() throws Throwable {
|
||||
if (this.handle != null) {
|
||||
// Kernel32.INSTANCE.CloseHandle(this.handle); // do not close the handle because the parent Process object might still be alive
|
||||
this.handle = null;
|
||||
|
||||
Reference in New Issue
Block a user