summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2021-09-28 19:00:10 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2021-09-29 13:12:36 +0900
commit5992b182a75c5d636b28a1bb7d1b40d4b765eff7 (patch)
tree8d7501fe6644ebad3d8a3d217ca83b4cd9dcc7b1
parent3d4bd8f87ab2dc2097b0faba3c137545d79787ed (diff)
downloadaul-1-5992b182a75c5d636b28a1bb7d1b40d4b765eff7.tar.gz
aul-1-5992b182a75c5d636b28a1bb7d1b40d4b765eff7.tar.bz2
aul-1-5992b182a75c5d636b28a1bb7d1b40d4b765eff7.zip
Add new functions for managing process group
To manage oom score of child processes of the application properly, AMD and resourced must know the process ID. When the child process calls the aul_proc_group_add() function, AMD sends the app group signal to resourced to notify the process group information. If the oom score of the main process is changed, the oom score of the child process is also changed by resourced. Adds: - aul_proc_group_add() - aul_proc_group_remove() Change-Id: Ic02f958bf32110e794efbdacc64c6cf8e3d8cfe4 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--include/aul_cmd.h2
-rw-r--r--include/aul_proc_group.h67
-rw-r--r--src/aul_cmd.c2
-rw-r--r--src/aul_proc_group.cc66
-rw-r--r--tool/aul_test/aul_test.c25
5 files changed, 162 insertions, 0 deletions
diff --git a/include/aul_cmd.h b/include/aul_cmd.h
index f9bbaddc..a654f43e 100644
--- a/include/aul_cmd.h
+++ b/include/aul_cmd.h
@@ -210,6 +210,8 @@ enum app_cmd {
RPC_PORT_DESTROY = 166,
RPC_PORT_EXIST = 167,
APP_WINDOW_ATTACH_BELOW = 168,
+ PROC_GROUP_ADD = 169,
+ PROC_GROUP_REMOVE = 170,
APP_CMD_MAX
};
diff --git a/include/aul_proc_group.h b/include/aul_proc_group.h
new file mode 100644
index 00000000..8297831e
--- /dev/null
+++ b/include/aul_proc_group.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AUL_PROC_GROUP_H__
+#define __AUL_RPOC_GROUP_H__
+
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <aul.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Adds the process to the process group.
+ * @remarks This function is only for App Framework internally.
+ * @remarks If the pid is not equal to the process ID of the caller,
+ * the caller MUST have a permission that is signed by platform certificate.
+ * If the caller doesn't have the permission, the function returns AUL_R_EILLACC.
+ * @since_tizen 6.5
+ * @param[in] pid The process ID
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #AUL_R_OK Successful
+ * @retval #AUL_R_EINVAL Invalid parameter
+ * @retval #AUL_R_ECOMM Communication error on send
+ * @retval #AUL_R_EILLACC Permission denied
+ */
+int aul_proc_group_add(pid_t pid);
+
+/**
+ * @brief Removes the process from the process group.
+ * @remarks This function is only for App Framework internally.
+ * @remarks If the pid is not equal to the process ID of the caller,
+ * the caller MUST have a permission that is signed by platform certificate.
+ * If the caller doesn't have the permission, the function returns AUL_R_EILLACC.
+ * @since_tizen 6.5
+ * @param[in] pid The process ID
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #AUL_R_OK Successful
+ * @retval #AUL_R_EINVAL Invalid parameter
+ * @retval #AUL_R_ECOMM Communication error on send
+ * @retval #AUL_R_EILLACC Permission denied
+ */
+int aul_proc_group_remove(pid_t pid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AUL_PROC_GROUP_H__ */
diff --git a/src/aul_cmd.c b/src/aul_cmd.c
index 540881fb..7ba85f04 100644
--- a/src/aul_cmd.c
+++ b/src/aul_cmd.c
@@ -212,6 +212,8 @@ API const char *aul_cmd_convert_to_string(int cmd)
"RPC_PORT_DESTROY",
"RPC_PORT_EXIST",
"APP_WINDOW_ATTACH_BELOW",
+ "PROC_GROUP_ADD",
+ "PROC_GROUP_REMOVE",
"CUSTOM_COMMAND"
};
diff --git a/src/aul_proc_group.cc b/src/aul_proc_group.cc
new file mode 100644
index 00000000..eddae48b
--- /dev/null
+++ b/src/aul_proc_group.cc
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/aul_proc_group.h"
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "app_request.h"
+#include "aul_api.h"
+#include "aul_util.h"
+#include "include/aul_error.h"
+#include "include/aul_sock.h"
+
+using namespace aul;
+using namespace aul::internal;
+
+extern "C" API int aul_proc_group_add(pid_t pid) {
+ if (pid < 1) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
+
+ int ret = AppRequest(PROC_GROUP_ADD, getuid())
+ .SetPid(pid)
+ .SendSimply();
+ if (ret < 0) {
+ _E("Failed to send the request. error(%d)", ret);
+ return aul_error_convert(ret);
+ }
+
+ return AUL_R_OK;
+}
+
+extern "C" API int aul_proc_group_remove(pid_t pid) {
+ if (pid < 1) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
+
+ int ret = AppRequest(PROC_GROUP_REMOVE, getuid())
+ .SetPid(pid)
+ .SendSimply();
+ if (ret < 0) {
+ _E("Failed to send the request. error(%d)", ret);
+ return aul_error_convert(ret);
+ }
+
+ return AUL_R_OK;
+}
diff --git a/tool/aul_test/aul_test.c b/tool/aul_test/aul_test.c
index 93d4a1c4..942505fb 100644
--- a/tool/aul_test/aul_test.c
+++ b/tool/aul_test/aul_test.c
@@ -27,6 +27,7 @@
#include "aul/api/aul_app_lifecycle.h"
#include "aul_svc.h"
#include "aul_proc.h"
+#include "aul_proc_group.h"
#include "menu_db_util.h"
#define MAX_LOCAL_BUFSZ 128
@@ -895,6 +896,26 @@ static int get_proc_extra_test(void)
return ret;
}
+static int add_proc_group_test(void)
+{
+ int ret;
+
+ printf("[aul_proc_group_add] %s\n", gargv[2]);
+ ret = aul_proc_group_add(atoi(gargv[2]));
+
+ return ret;
+}
+
+static int remove_proc_group_test(void)
+{
+ int ret;
+
+ printf("[aul_proc_group_remove] %s\n", gargv[2]);
+ ret = aul_proc_group_remove(atoi(gargv[2]));
+
+ return ret;
+}
+
static int test_regex()
{
char *token;
@@ -1049,6 +1070,10 @@ static test_func_t test_func[] = {
"[usage] get_proc_name <pid>"},
{"get_proc_extra", get_proc_extra_test, "aul_proc_get_extra",
"[usage] get_proc_extra <pid>"},
+ {"add_proc_group", add_proc_group_test, "aul_proc_group_add",
+ "[usage] add_proc_group <pid>"},
+ {"remove_proc_group", remove_proc_group_test, "aul_proc_group_remove",
+ "[usage] remove_proc_group <pid>"},
};
int callfunc(char *testname)