• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • servicestub
priority.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE Project
2  Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
3 
4  Parts of this file are based on code from Strigi
5  Copyright (C) 2006-2007 Jos van den Oever <jos@vandenoever.info>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License version 2 as published by the Free Software Foundation.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #include "priority.h"
23 
24 #ifndef _GNU_SOURCE
25 #define _GNU_SOURCE
26 #endif
27 
28 #include <QtCore/QDebug>
29 
30 #include <sys/time.h>
31 #include <sys/resource.h>
32 
33 #include <unistd.h>
34 #ifndef _WIN32
35 #include <sys/syscall.h>
36 #include <errno.h>
37 
38 #include <sched.h>
39 #endif
40 
41 #ifdef SYS_ioprio_set
42 namespace {
43 #ifndef IOPRIO_CLASS_IDLE
44  enum {
45  IOPRIO_CLASS_NONE,
46  IOPRIO_CLASS_RT,
47  IOPRIO_CLASS_BE,
48  IOPRIO_CLASS_IDLE
49  };
50 #endif
51 
52 #ifndef IOPRIO_WHO_PROCESS
53  enum {
54  IOPRIO_WHO_PROCESS = 1,
55  IOPRIO_WHO_PGRP,
56  IOPRIO_WHO_USER
57  };
58 #endif
59 
60 #ifndef IOPRIO_CLASS_SHIFT
61  const int IOPRIO_CLASS_SHIFT = 13;
62 #endif
63 }
64 #endif
65 
66 
67 bool lowerIOPriority()
68 {
69 #ifdef SYS_ioprio_set
70  if ( syscall( SYS_ioprio_set, IOPRIO_WHO_PROCESS, 0, IOPRIO_CLASS_IDLE<<IOPRIO_CLASS_SHIFT ) < 0 ) {
71  qDebug( "cannot set io scheduling to idle (%s). Trying best effort.\n", strerror( errno ));
72  if ( syscall( SYS_ioprio_set, IOPRIO_WHO_PROCESS, 0, 7|IOPRIO_CLASS_BE<<IOPRIO_CLASS_SHIFT ) < 0 ) {
73  qDebug( "cannot set io scheduling to best effort.\n");
74  return false;
75  }
76  }
77  return true;
78 #else
79  return false;
80 #endif
81 }
82 
83 
84 bool lowerPriority()
85 {
86 #ifndef Q_OS_WIN
87  return !setpriority( PRIO_PROCESS, 0, 19 );
88 #else
89  return false;
90 #endif
91 }
92 
93 
94 // FIXME: is this really useful? Should we better use SCHED_IDLE?
95 bool lowerSchedulingPriority()
96 {
97 #ifdef SCHED_BATCH
98  struct sched_param param;
99  memset( &param, 0, sizeof(param) );
100  param.sched_priority = 0;
101  return !sched_setscheduler( 0, SCHED_BATCH, &param );
102 #else
103  return false;
104 #endif
105 }
lowerSchedulingPriority
bool lowerSchedulingPriority()
Definition: priority.cpp:95
lowerPriority
bool lowerPriority()
Definition: priority.cpp:84
priority.h
lowerIOPriority
bool lowerIOPriority()
Definition: priority.cpp:67
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal