2 * Copyright © 2012-2013 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
18 #ifndef CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_
19 #define CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_
21 #include <core/posix/visibility.h>
35 * This file displays the current score that the kernel gives to this process
36 * for the purpose of selecting a process for the OOM-killer. A higher score
37 * means that the process is more likely to be selected by the OOM-killer. The
38 * basis for this score is the amount of memory used by the process, with
39 * increases (+) or decreases (-) for factors including:
41 * - whether the process creates a lot of children using fork(2) (+);
42 * - whether the process has been running a long time, or has used a lot of CPU time (-);
43 * - whether the process has a low nice value (i.e., > 0) (+);
44 * - whether the process is privileged (-); and
45 * - whether the process is making direct hardware access (-).
47 * The oom_score also reflects the adjustment specified by the oom_score_adj or
48 * oom_adj setting for the process.
50 struct CORE_POSIX_DLL_PUBLIC OomScore
52 int value = 0; ///< Current OomScore as calculated by the kernel.
56 * \brief Read the OomScore for a process instance.
57 * \throws std::runtime_error in case of errors.
58 * \param [in] process The process to read the score for.
59 * \param [out] score The destination to store the value in.
61 CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, OomScore& score);
67 #endif // CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_