/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "com_sun_management_UnixOperatingSystem.h"
#include <mach/task_info.h>
{
// This code is influenced by the darwin top source
if (kr != KERN_SUCCESS) {
return -1;
}
jlong used = load.cpu_ticks[CPU_STATE_USER] + load.cpu_ticks[CPU_STATE_NICE] + load.cpu_ticks[CPU_STATE_SYSTEM];
if (last_used == 0 || last_total == 0) {
// First call, just set the last values
last_total = total;
// return 0 since we have no data, not -1 which indicates error
return 0;
}
last_total = total;
return cpu;
}
#define TIME_VALUE_TO_TIMEVAL(a, r) do { \
(r)->tv_usec = (a)->microseconds; \
} while (0)
{
// This code is influenced by the darwin top source
if (kr != KERN_SUCCESS) {
// Most likely cause: |task| is a zombie.
return -1;
}
&count);
if (kr != KERN_SUCCESS) {
// Most likely cause: |task| is a zombie.
return -1;
}
/* Set total_time. */
// thread info contains live time...
// ... task info contains terminated time.
return -1;
}
if ((last_task_time == 0) || (last_time == 0)) {
// First call, just set the last values.
// return 0 since we have no data, not -1 which indicates error
return 0;
}
if (time_delta == 0) {
return -1;
}
return cpu;
}