4162N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 4162N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4162N/A * This code is free software; you can redistribute it and/or modify it 4162N/A * under the terms of the GNU General Public License version 2 only, as 4162N/A * published by the Free Software Foundation. Oracle designates this 4162N/A * particular file as subject to the "Classpath" exception as provided 4162N/A * by Oracle in the LICENSE file that accompanied this code. 4162N/A * This code is distributed in the hope that it will be useful, but WITHOUT 4162N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4162N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4162N/A * version 2 for more details (a copy is included in the LICENSE file that 4162N/A * You should have received a copy of the GNU General Public License version 4162N/A * 2 along with this work; if not, write to the Free Software Foundation, 4162N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4162N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4162N/A * Return the total number of ticks since the system was booted. 4162N/A * If the usedTicks parameter is not NULL, it will be filled with 4162N/A * the number of ticks spent on actual processes (user, system or 4162N/A * nice processes) since system boot. Note that this is the total number 4162N/A * of "executed" ticks on _all_ CPU:s, that is on a n-way system it is 4162N/A * n times the number of ticks that has passed in clock time. 4162N/A * Returns a negative value if the reading of the ticks failed. 4162N/A //find the line for requested cpu faster to just iterate linefeeds? 4162N/A /** skip through pid and exec name. the exec name _could be wacky_ (renamed) and 4162N/A // skip the ')' and the following space but check that the buffer is long enough 4162N/A/** read user and system ticks from a named procfile, assumed to be in 'stat' format then. */ 4162N/A * Return the number of ticks spent in any of the processes belonging 4162N/A * This method must be called first, before any data can be gathererd. 4162N/A * Return the load of the CPU as a double. 1.0 means the CPU process uses all 4162N/A * available time for user or system processes, 0.0 means the CPU uses all time 4162N/A * Returns a negative value if there is a problem in determining the CPU load. 4162N/A // seems like we sometimes end up with less kernel ticks when 4162N/A // BUG9044876, normalize return values to sane values 4162N/A // Cap total systemload to 1.0