8e7b9a47a5441ac3c0709b9139c9b73bfb290eec
[iec.git] / src / type3_AndroidCloud / anbox-master / external / process-cpp-minimal / include / core / posix / linux / proc / process / oom_score.h
1 /*
2  * Copyright © 2012-2013 Canonical Ltd.
3  *
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.
7  *
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.
12  *
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/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 #ifndef CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_
19 #define CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_
20
21 #include <core/posix/visibility.h>
22
23 namespace core
24 {
25 namespace posix
26 {
27 class Process;
28 namespace linux
29 {
30 namespace proc
31 {
32 namespace process
33 {
34 /**
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:
40  *
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 (-).
46  *
47  * The oom_score also reflects the adjustment specified by the oom_score_adj or
48  * oom_adj setting for the process.
49  */
50 struct CORE_POSIX_DLL_PUBLIC OomScore
51 {
52     int value = 0; ///< Current OomScore as calculated by the kernel.
53 };
54
55 /**
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.
60  */
61 CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, OomScore& score);
62 }
63 }
64 }
65 }
66 }
67 #endif // CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_