Commit 51de9e6f authored by Martyn James Russell's avatar Martyn James Russell

Use SCHED_IDLE for the process scheduling to improve responsiveness of

	* src/libtracker-common/tracker-ioprio.c:
	* src/tracker-indexer/tracker-main.c: 
	* src/trackerd/tracker-main.c: Use SCHED_IDLE for the process
	scheduling to improve responsiveness of phone calls and other real
	time applications. Fixes NB#95573.

svn path=/trunk/; revision=2923
parent 03b4a7f1
2009-02-12 Martyn Russell <martyn@imendio.com>
* src/libtracker-common/tracker-ioprio.c:
* src/tracker-indexer/tracker-main.c:
* src/trackerd/tracker-main.c: Use SCHED_IDLE for the process
scheduling to improve responsiveness of phone calls and other real
time applications. Fixes NB#95573.
2009-02-12 Mikael Ottela <mikael.ottela@ixonos.com>
* src/tracker-extract/tracker-main.c
......
......@@ -128,7 +128,7 @@ set_io_priority_best_effort (int ioprio_val)
void
tracker_ioprio_init (void)
{
g_message ("Setting IO priority...");
g_message ("Setting IO priority");
if (set_io_priority_idle () == -1) {
g_message ("Could not set idle IO priority, attempting best effort of 7");
......
......@@ -26,6 +26,8 @@
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/sched.h>
#include <sched.h>
#include <glib.h>
#include <glib-object.h>
......@@ -202,6 +204,53 @@ initialize_signal_handler (void)
#endif
}
static void
initialize_priority (void)
{
struct sched_param sp;
/* Set disk IO priority and scheduling */
tracker_ioprio_init ();
/* Set process priority:
* The nice() function uses attribute "warn_unused_result" and
* so complains if we do not check its returned value. But it
* seems that since glibc 2.2.4, nice() can return -1 on a
* successful call so we have to check value of errno too.
* Stupid...
*/
g_message ("Setting process priority");
if (nice (19) == -1) {
const gchar *str = g_strerror (errno);
g_message ("Couldn't set nice value to 19, %s",
str ? str : "no error given");
}
/* Set process scheduling parameters:
* This is used so we don't steal scheduling priority from
* the most important applications - like the phone
* application which has a real time requirement here. This
* is detailed in Nokia bug #95573
*/
g_message ("Setting scheduling priority");
if (sched_getparam (0, &sp) == 0) {
if (sched_setscheduler (0, SCHED_IDLE, &sp) != 0) {
const gchar *str = g_strerror (errno);
g_message ("Couldn't set scheduler priority, %s",
str ? str : "no error given");
}
} else {
const gchar *str = g_strerror (errno);
g_message ("Couldn't get scheduler priority, %s",
str ? str : "no error given");
}
}
static gboolean
quit_timeout_cb (gpointer user_data)
{
......@@ -300,6 +349,9 @@ main (gint argc, gchar *argv[])
return EXIT_FAILURE;
}
/* This makes sure we don't steal all the system's resources */
initialize_priority ();
/* Initialize logging */
config = tracker_config_new ();
language = tracker_language_new (config);
......
......@@ -33,6 +33,8 @@
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <linux/sched.h>
#include <sched.h>
#include <glib.h>
#include <glib/gi18n.h>
......@@ -481,6 +483,53 @@ initialize_signal_handler (void)
#endif /* G_OS_WIN32 */
}
static void
initialize_priority (void)
{
struct sched_param sp;
/* Set disk IO priority and scheduling */
tracker_ioprio_init ();
/* Set process priority:
* The nice() function uses attribute "warn_unused_result" and
* so complains if we do not check its returned value. But it
* seems that since glibc 2.2.4, nice() can return -1 on a
* successful call so we have to check value of errno too.
* Stupid...
*/
g_message ("Setting process priority");
if (nice (19) == -1) {
const gchar *str = g_strerror (errno);
g_message ("Couldn't set nice value to 19, %s",
str ? str : "no error given");
}
/* Set process scheduling parameters:
* This is used so we don't steal scheduling priority from
* the most important applications - like the phone
* application which has a real time requirement here. This
* is detailed in Nokia bug #95573
*/
g_message ("Setting scheduling priority");
if (sched_getparam (0, &sp) == 0) {
if (sched_setscheduler (0, SCHED_IDLE, &sp) != 0) {
const gchar *str = g_strerror (errno);
g_message ("Couldn't set scheduler priority, %s",
str ? str : "no error given");
}
} else {
const gchar *str = g_strerror (errno);
g_message ("Couldn't get scheduler priority, %s",
str ? str : "no error given");
}
}
static void
initialize_locations (void)
{
......@@ -950,21 +999,8 @@ main (gint argc, gchar *argv[])
return EXIT_FAILURE;
}
/* Set IO priority */
tracker_ioprio_init ();
/* nice() uses attribute "warn_unused_result" and so complains
* if we do not check its returned value. But it seems that
* since glibc 2.2.4, nice() can return -1 on a successful
* call so we have to check value of errno too. Stupid...
*/
if (nice (19) == -1 && errno) {
const gchar *str;
str = g_strerror (errno);
g_message ("Couldn't set nice value to 19, %s",
str ? str : "no error given");
}
/* This makes sure we don't steal all the system's resources */
initialize_priority ();
/* This makes sure we have all the locations like the data
* dir, user data dir, etc all configured.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment