From 375d4c600115351951b1ccd82798c5a4fa0b8e5e Mon Sep 17 00:00:00 2001 From: Krzysztof Sasiak Date: Thu, 23 May 2013 15:41:36 +0200 Subject: [PATCH] Implementation of new OOM policy Change-Id: Ieb9e05cea483c5c3c93bf041e6d9fbb71ba2bd70 --- packaging/osp-appfw.spec | 2 +- src/server/CMakeLists.txt | 1 + src/server/app/FApp_AulServer.cpp | 20 +++++++++++++++++++- src/server/inc/FApp_AulServer.h | 3 +++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packaging/osp-appfw.spec b/packaging/osp-appfw.spec index 31ac8b6..ce30d96 100755 --- a/packaging/osp-appfw.spec +++ b/packaging/osp-appfw.spec @@ -26,7 +26,7 @@ BuildRequires: pkgconfig(capi-network-tethering) BuildRequires: pkgconfig(capi-network-wifi) BuildRequires: pkgconfig(capi-network-wifi-direct) BuildRequires: pkgconfig(capi-media-sound-manager) -BuildRequires: pkgconfig(sysman) +BuildRequires: pkgconfig(sysman) >= 0.2.30 BuildRequires: pkgconfig(tapi) BuildRequires: pkgconfig(alarm-service) BuildRequires: pkgconfig(appsvc) diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index ec94998..b88028d 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -10,6 +10,7 @@ INCLUDE_DIRECTORIES ( ${CMAKE_SOURCE_DIR}/src/security ${CMAKE_SOURCE_DIR}/src/app/inc inc + /usr/include/sysman ) SET (${this_target}_SOURCE_FILES diff --git a/src/server/app/FApp_AulServer.cpp b/src/server/app/FApp_AulServer.cpp index 267a974..896b88f 100755 --- a/src/server/app/FApp_AulServer.cpp +++ b/src/server/app/FApp_AulServer.cpp @@ -45,6 +45,7 @@ #include "FApp_Types.h" #include "FApp_AulServer.h" #include "FApp_TemplateUtil.h" +#include "oom_policy.h" #ifdef __cplusplus extern "C" { @@ -221,6 +222,23 @@ _AulServer::SetOomAdj(int pid, int adj) } result +_AulServer::SetOomScoreAdj(int pid, AppOomScore adj) +{ + result r = E_SUCCESS; + char buf[FILENAME_MAX]; + FILE *fP = NULL; + + snprintf(buf, FILENAME_MAX, "/proc/%d/oom_score_adj", pid); + fP = fopen(buf, "w"); + SysTryReturnResult(NID_APP, fP != NULL, E_SYSTEM, "oom_adj change failed with %s.", strerror(errno)); + + fprintf(fP, "%d", adj); + fclose(fP); + + return r; +} + +result _AulServer::SetPowerOffNotiListener( void (*powerOffCb)(void *pData), void *pData) { int heyFd = heynoti_init(); @@ -332,7 +350,7 @@ int _AulServer::CreateProcess(const AppId& appId) int currentPid = getpid(); - //SetOomAdj(currentPid, -17); // set oom_adj to -17 for system service + SetOomScoreAdj(currentPid, OOM_SCORE_SYS_SERVICE); // set oom_score_adj for system service prctl(PR_SET_PDEATHSIG, SIGTERM); diff --git a/src/server/inc/FApp_AulServer.h b/src/server/inc/FApp_AulServer.h index ab22aea..64bc196 100755 --- a/src/server/inc/FApp_AulServer.h +++ b/src/server/inc/FApp_AulServer.h @@ -26,6 +26,7 @@ #include #include #include +#include #define MAX_SLP_PACKAGE_ID 128 @@ -53,6 +54,8 @@ public: static result SetOomAdj(int pid, int adj); + static result SetOomScoreAdj(int pid, AppOomScore adj); + static result SetPowerOffNotiListener(void (*powerOffCb)(void *pData), void *pData); static int GetAppType(const Tizen::Base::String& category); -- 2.7.4