tizen 2.3.1 release
[kernel/api/system-resource.git] / src / proc-stat / include / proc-main.h
1 /*
2  * resourced
3  *
4  * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 /**
21  * @file proc-main.h
22  * @desc intialize and start pthread for lowmem handler
23  **/
24
25 #ifndef __PROC_MAIN_H__
26 #define __PROC_MAIN_H__
27
28 #include <unistd.h>
29 #include <glib.h>
30
31 #include "daemon-options.h"
32 #include "resourced.h"
33 #include "const.h"
34
35 #define PROC_BUF_MAX 64
36 #define PROC_NAME_MAX 512
37
38 typedef GSList *pid_info_list;
39
40 enum application_type {
41         RESOURCED_APP_TYPE_UNKNOWN,
42         RESOURCED_APP_TYPE_GUI,
43         RESOURCED_APP_TYPE_SERVICE,
44         RESOURCED_APP_TYPE_GROUP,
45 };
46
47 struct pid_info_t {
48         pid_t pid;
49         enum application_type type; /* not so fancy */
50 };
51
52 struct proc_process_info_t {
53         char appid[MAX_PATH_LENGTH];
54         char pkgname[MAX_PATH_LENGTH];
55         pid_info_list pids;
56         int proc_exclude;
57         int runtime_exclude;
58         int memcg_idx;
59         int state;
60         int type;
61 };
62
63 struct proc_status {
64         pid_t pid;
65         char* appid;
66         struct proc_process_info_t *processinfo;
67 };
68
69 enum proc_exclude_type {
70         PROC_EXCLUDE,
71         PROC_INCLUDE,
72 };
73
74 enum {
75         LCD_STATE_ON,
76         LCD_STATE_OFF,
77 };
78
79 enum proc_prelaunch_flags {
80         PROC_LARGE_HEAP = 0x01u,        /* for mark large heap */
81         PROC_SIGTERM    = 0x02u,        /* for make killer kill victim by SIGTERM */
82 };
83
84 extern int current_lcd_state;
85
86
87 void proc_add_pid_list(struct proc_process_info_t *process_info, int pid, enum application_type type);
88
89 int resourced_proc_init(const struct daemon_opts *opts);
90
91 /**
92  * @desc This function handle PROC_ typs @see
93  */
94 int resourced_proc_action(int type, int argnum, char **arg);
95
96 int resourced_proc_excluded(const char *app_name);
97
98 int resourced_proc_status_change(int type, pid_t pid, char* app_name,  char* pkg_name);
99
100 struct proc_process_info_t *find_process_info(const char *appid, const pid_t pid, const char *pkgid);
101
102 struct pid_info_t *new_pid_info(const pid_t pid, const int type);
103
104 void proc_set_process_info_memcg(struct proc_process_info_t *process_info, int memcg_idx);
105 resourced_ret_c proc_set_runtime_exclude_list(const int pid, int type);
106 struct proc_process_info_t *proc_add_process_list(const int type, const pid_t pid, const char *appid, const char *pkgid);
107 int proc_remove_process_list(const pid_t pid);
108 void proc_set_apptype(const char *appid, const char *pkgid, int type);
109
110
111 #endif /*__PROC_MAIN_H__ */