static void initialize_priority_and_scheduling (TrackerSchedIdle sched_idle, gboolean first_time_index) { /* Set CPU priority */ if (sched_idle == TRACKER_SCHED_IDLE_ALWAYS || (sched_idle == TRACKER_SCHED_IDLE_FIRST_INDEX && first_time_index)) { tracker_sched_idle (); } /* 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 priority nice level to 19"); 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"); } }
static void test_sched_set_and_get (void) { g_assert (scheduler_is (SCHED_OTHER)); g_assert (tracker_sched_idle ()); #ifdef __linux__ g_assert (scheduler_is (SCHED_IDLE)); #endif }
int main (int argc, char **argv) { GApplication *app; gint exit_status; tracker_sched_idle (); tracker_ioprio_init (); errno = 0; if (nice (19) == -1 && errno != 0) { const gchar *str; str = g_strerror (errno); g_warning ("Couldn't set nice value to 19, %s", (str != NULL) ? str : "no error given"); } app = gom_application_new (MINER_BUS_NAME, MINER_TYPE); if (g_getenv (MINER_NAME "_MINER_PERSIST") != NULL) g_application_hold (app); g_unix_signal_add_full (G_PRIORITY_DEFAULT, SIGTERM, signal_handler_cb, app, NULL); g_unix_signal_add_full (G_PRIORITY_DEFAULT, SIGINT, signal_handler_cb, app, NULL); exit_status = g_application_run (app, argc, argv); g_object_unref (app); return exit_status; }