Decrease CPU loads for resource thread 45/24145/1
authorjonghyun.ho <jonghyun.ho@samsung.com>
Fri, 4 Jul 2014 13:05:48 +0000 (22:05 +0900)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 16:07:09 +0000 (17:07 +0100)
[problem]     Gallery is stuck sometimes if it has so many images.
[cause]       Heavy works in resource thread.
[solution]    Decrease CPU loads for resource thread using environment variable.
              Have DALI_RESOURCE_THREAD_IDLE_PRIORITY set, and idle priority for the resources
              will be used.

Change-Id: Iab8b3a5687046831329740429b2ae586dc9ec5cb
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
platform-abstractions/slp/resource-loader/resource-thread-base.cpp

index 41c65ca..4dcfaca 100644 (file)
@@ -33,6 +33,11 @@ const Integration::ResourceId NO_REQUEST = Integration::ResourceId(0) - 1;
 namespace SlpPlatform
 {
 
+namespace
+{
+const char * const IDLE_PRIORITY_ENVIRONMENT_VARIABLE_NAME = "DALI_RESOURCE_THREAD_IDLE_PRIORITY";
+} // unnamed namespace
+
 ResourceThreadBase::ResourceThreadBase(ResourceLoader& resourceLoader)
 : mResourceLoader( resourceLoader ), mCurrentRequestId( NO_REQUEST ), mPaused( false )
 {
@@ -145,6 +150,16 @@ void ResourceThreadBase::Resume()
 
 void ResourceThreadBase::ThreadLoop()
 {
+  // TODO: Use Environment Options
+  const char* threadPriorityIdleRequired = std::getenv( IDLE_PRIORITY_ENVIRONMENT_VARIABLE_NAME );
+  if( threadPriorityIdleRequired )
+  {
+    // if the parameter exists then set up an idle priority for this thread
+    struct sched_param sp;
+    sp.sched_priority = 0;
+    sched_setscheduler(0, SCHED_IDLE, &sp);
+  }
+
   InstallLogging();
 
   while( !mResourceLoader.IsTerminating() )