Commit 04caa7ff authored by Martyn Russell's avatar Martyn Russell

libtracker-common: Added functionality for SCHED_IDLE scheduler priority

Also added calls the tracker-miner-fs and tracker-extract
parent e0afdfb4
......@@ -25,6 +25,7 @@ libtracker_common_la_SOURCES = \
tracker-ioprio.c \
tracker-keyfile-object.c \
tracker-log.c \
tracker-sched.c \
tracker-type-utils.c \
tracker-utils.c \
tracker-crc32.c \
......@@ -43,6 +44,7 @@ noinst_HEADERS = \
tracker-file-utils.h \
tracker-keyfile-object.h \
tracker-ontologies.h \
tracker-sched.h \
tracker-type-utils.h \
tracker-utils.h \
tracker-crc32.h \
......
......@@ -38,6 +38,7 @@
#include "tracker-log.h"
#include "tracker-ontologies.h"
#include "tracker-os-dependant.h"
#include "tracker-sched.h"
#include "tracker-type-utils.h"
#include "tracker-utils.h"
#include "tracker-locale.h"
......
/*
* Copyright (C) 2011, Nokia <ivan.frade@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#ifdef __linux__
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <errno.h>
#include <sched.h>
#include <glib.h>
#include "tracker-sched.h"
gboolean
tracker_sched_idle (void)
{
struct sched_param sp;
/* 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 scheduler policy to SCHED_IDLE");
if (sched_getparam (0, &sp) == 0) {
if (sched_setscheduler (0, SCHED_IDLE, &sp) != 0) {
const gchar *str = g_strerror (errno);
g_warning ("Could not set scheduler policy, %s",
str ? str : "no error given");
return FALSE;
}
} else {
const gchar *str = g_strerror (errno);
g_warning ("Could not get scheduler policy, %s",
str ? str : "no error given");
return FALSE;
}
return TRUE;
}
#else /* __linux__ */
#include <glib.h>
#include "tracker-sched.h"
gboolean
tracker_sched_idle (void)
{
return TRUE;
}
#endif /* __linux__ */
/*
* Copyright (C) 2011, Nokia <ivan.frade@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __LIBTRACKER_COMMON_SCHED_H__
#define __LIBTRACKER_COMMON_SCHED_H__
G_BEGIN_DECLS
#if !defined (__LIBTRACKER_COMMON_INSIDE__) && !defined (TRACKER_COMPILATION)
#error "only <libtracker-common/tracker-common.h> must be included directly."
#endif
gboolean tracker_sched_idle (void);
G_END_DECLS
#endif /* __LIBTRACKER_COMMON_SCHED_H__ */
......@@ -26,10 +26,6 @@
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#if defined(__linux__)
#include <linux/sched.h>
#endif
#include <sched.h>
#include <glib.h>
#include <glib-object.h>
......@@ -39,6 +35,7 @@
#include <libtracker-common/tracker-log.h>
#include <libtracker-common/tracker-ontologies.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-sched.h>
#include <libtracker-miner/tracker-miner.h>
......@@ -172,8 +169,11 @@ initialize_signal_handler (void)
}
static void
initialize_priority (void)
initialize_priority_and_scheduling (void)
{
/* Set CPU priority */
tracker_sched_idle ();
/* Set disk IO priority and scheduling */
tracker_ioprio_init ();
......@@ -714,9 +714,6 @@ main (gint argc, gchar *argv[])
initialize_signal_handler ();
/* This makes sure we don't steal all the system's resources */
initialize_priority ();
/* Initialize logging */
config = tracker_config_new ();
......@@ -735,6 +732,9 @@ main (gint argc, gchar *argv[])
sanity_check_option_values (config);
/* This makes sure we don't steal all the system's resources */
initialize_priority_and_scheduling ();
main_loop = g_main_loop_new (NULL, FALSE);
g_message ("Checking if we're running as a daemon:");
......
......@@ -442,6 +442,7 @@ tracker_extract_LDADD = \
$(top_builddir)/src/libtracker-extract/libtracker-extract-@TRACKER_API_VERSION@.la \
$(top_builddir)/src/libtracker-sparql-backend/libtracker-sparql-@TRACKER_API_VERSION@.la \
$(top_builddir)/src/libtracker-miner/libtracker-miner-@TRACKER_API_VERSION@.la \
$(top_builddir)/src/libtracker-data/libtracker-data.la \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
$(BUILD_LIBS) \
$(TRACKER_EXTRACT_LIBS)
......
......@@ -28,10 +28,6 @@
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#if defined(__linux__)
#include <linux/sched.h>
#endif
#include <sched.h>
#include <glib.h>
#include <glib-object.h>
......@@ -47,6 +43,7 @@
#include <libtracker-common/tracker-os-dependant.h>
#include <libtracker-common/tracker-ioprio.h>
#include <libtracker-common/tracker-locale.h>
#include <libtracker-common/tracker-sched.h>
#include "tracker-albumart.h"
#include "tracker-config.h"
......@@ -118,8 +115,11 @@ static GOptionEntry entries[] = {
};
static void
initialize_priority (void)
initialize_priority_and_scheduling (void)
{
/* Set CPU priority */
tracker_sched_idle ();
/* Set disk IO priority and scheduling */
tracker_ioprio_init ();
......@@ -273,7 +273,7 @@ run_standalone (void)
tracker_albumart_init ();
/* This makes sure we don't steal all the system's resources */
initialize_priority ();
initialize_priority_and_scheduling ();
file = g_file_new_for_commandline_arg (filename);
uri = g_file_get_uri (file);
......@@ -398,7 +398,7 @@ main (int argc, char *argv[])
sanity_check_option_values (config);
/* This makes sure we don't steal all the system's resources */
initialize_priority ();
initialize_priority_and_scheduling ();
tracker_memory_setrlimits ();
if (disable_shutdown) {
......
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