From 947b1b9785ec60f095ca7fcc1841d4ef8214524f Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Mon, 4 Jul 2022 14:45:19 +0900 Subject: [PATCH] Modify tid and pid from int to pid_t Change-Id: I6bf4914fb1dc7f0c75c73e0292264b48625249bf Signed-off-by: Unsung Lee (cherry picked from commit 56d356846f6ddea53d60107268e65ed899516528) --- include/cpu-boosting-type.h | 6 ++++-- include/cpu-boosting.h | 4 ++-- src/cpu-boosting.c | 8 ++++---- src/plugin/plugin.c | 8 ++++---- tests/main.c | 4 ++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/cpu-boosting-type.h b/include/cpu-boosting-type.h index be23729..79084ee 100644 --- a/include/cpu-boosting-type.h +++ b/include/cpu-boosting-type.h @@ -23,6 +23,8 @@ #ifndef __TIZEN_SYSTEM_CPU_BOOSTING_TYPE_H__ #define __TIZEN_SYSTEM_CPU_BOOSTING_TYPE_H__ +#include + #ifdef __cplusplus extern "C" { #endif @@ -36,8 +38,8 @@ typedef enum resource_cpu_boosting_level { } cpu_boosting_level_e; typedef struct resource_pid_info { - int pid; - int *tid; + pid_t pid; + pid_t *tid; int tid_count; } resource_pid_t; diff --git a/include/cpu-boosting.h b/include/cpu-boosting.h index e705d76..c62a20c 100644 --- a/include/cpu-boosting.h +++ b/include/cpu-boosting.h @@ -99,7 +99,7 @@ int resource_get_cpu_boosting_level (resource_pid_t pid, cpu_boosting_level_info * * @return 0 on success, otherwise a negative error value. */ -int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int timeout_msec); +int resource_set_cpu_inheritance (pid_t source_tid, const char *dest_process, int timeout_msec); /** * @brief Clear cpu resource inheritance from the source tid to the destination process (pid/tids). @@ -112,7 +112,7 @@ int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int * * @return 0 on success, otherwise a negative error value. */ -int resource_clear_cpu_inheritance (int source_tid, const char *dest_process); +int resource_clear_cpu_inheritance (pid_t source_tid, const char *dest_process); /** * @brief Register a destination process (pid/tids) for cpu resource inheritance. diff --git a/src/cpu-boosting.c b/src/cpu-boosting.c index 884b4f5..3841978 100644 --- a/src/cpu-boosting.c +++ b/src/cpu-boosting.c @@ -124,10 +124,10 @@ API int resource_get_cpu_boosting_level (resource_pid_t pid, return ret; } -API int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int timeout_msec) +API int resource_set_cpu_inheritance (pid_t source_tid, const char *dest_process, int timeout_msec) { int ret; - int (*func)(int source_tid, const char *dest_process, int timeout_msec) = NULL; + int (*func)(pid_t source_tid, const char *dest_process, int timeout_msec) = NULL; ret = open_cpu_boosting_plugin(); if (ret != RESOURCE_ERROR_NONE) @@ -148,10 +148,10 @@ API int resource_set_cpu_inheritance (int source_tid, const char *dest_process, return ret; } -API int resource_clear_cpu_inheritance (int source_tid, const char *dest_process) +API int resource_clear_cpu_inheritance (pid_t source_tid, const char *dest_process) { int ret; - int (*func)(int source_tid, const char *dest_process) = NULL; + int (*func)(pid_t source_tid, const char *dest_process) = NULL; ret = open_cpu_boosting_plugin(); if (ret != RESOURCE_ERROR_NONE) diff --git a/src/plugin/plugin.c b/src/plugin/plugin.c index a3588fa..598c1b3 100644 --- a/src/plugin/plugin.c +++ b/src/plugin/plugin.c @@ -96,7 +96,7 @@ static inline bool resource_cpu_boosting_level_input_is_valid(cpu_boosting_level API int resource_set_cpu_boosting (resource_pid_t pid, cpu_boosting_level_e level, int timeout_msec) { - int tid; + pid_t tid; int byte; int ret = 0; int sock; @@ -126,7 +126,7 @@ API int resource_set_cpu_boosting (resource_pid_t pid, input.pid.tid_count = 1; } - input.body_size = input.pid.tid_count * sizeof(int); + input.body_size = input.pid.tid_count * sizeof(pid_t); } byte = send(sock, (const void *)&input, sizeof(input), 0); @@ -186,14 +186,14 @@ API int resource_get_cpu_boosting_level (resource_pid_t pid, return 0; } -API int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int timeout_msec) +API int resource_set_cpu_inheritance (pid_t source_tid, const char *dest_process, int timeout_msec) { _D("[CPU-BOOSTING-PLUGIN] %s called", __func__); return 0; } -API int resource_clear_cpu_inheritance (int source_tid, const char *dest_process) +API int resource_clear_cpu_inheritance (pid_t source_tid, const char *dest_process) { _D("[CPU-BOOSTING-PLUGIN] %s called", __func__); diff --git a/tests/main.c b/tests/main.c index 1e7f0a4..fd4d8e0 100644 --- a/tests/main.c +++ b/tests/main.c @@ -46,7 +46,7 @@ static void *thread_worker(void *arg) { - int *tid = (int *)arg; + pid_t *tid = (pid_t *)arg; if (tid) *tid = gettid(); @@ -145,7 +145,7 @@ static void one_process_multi_thread_test(int tid_count) if (tid_count < 1) return; - pid.tid = (int *)calloc(tid_count, sizeof(int)); + pid.tid = (pid_t *)calloc(tid_count, sizeof(pid_t)); if (pid.tid == NULL) { _E("[CPU-BOOSTING-TEST] Failed to allocate memory for tids"); return; -- 2.7.4