• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2 
3 #ifndef foortkithfoo
4 #define foortkithfoo
5 
6 /***
7   Copyright 2009 Lennart Poettering
8   Copyright 2010 David Henningsson <diwic@ubuntu.com>
9 
10   Permission is hereby granted, free of charge, to any person
11   obtaining a copy of this software and associated documentation files
12   (the "Software"), to deal in the Software without restriction,
13   including without limitation the rights to use, copy, modify, merge,
14   publish, distribute, sublicense, and/or sell copies of the Software,
15   and to permit persons to whom the Software is furnished to do so,
16   subject to the following conditions:
17 
18   The above copyright notice and this permission notice shall be
19   included in all copies or substantial portions of the Software.
20 
21   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28   SOFTWARE.
29 ***/
30 
31 #include <sys/types.h>
32 #include <dbus/dbus.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /* This is the reference implementation for a client for
39  * RealtimeKit. You don't have to use this, but if do, just copy these
40  * sources into your repository */
41 
42 #define RTKIT_SERVICE_NAME "org.freedesktop.RealtimeKit1"
43 #define RTKIT_OBJECT_PATH "/org/freedesktop/RealtimeKit1"
44 
45 /* This is mostly equivalent to sched_setparam(thread, SCHED_RR, {
46  * .sched_priority = priority }). 'thread' needs to be a kernel thread
47  * id as returned by gettid(), not a pthread_t! If 'thread' is 0 the
48  * current thread is used. The returned value is a negative errno
49  * style error code, or 0 on success. */
50 int rtkit_make_realtime(DBusConnection *system_bus, pid_t thread, int priority);
51 
52 /* This is mostly equivalent to setpriority(PRIO_PROCESS, thread,
53  * nice_level). 'thread' needs to be a kernel thread id as returned by
54  * gettid(), not a pthread_t! If 'thread' is 0 the current thread is
55  * used. The returned value is a negative errno style error code, or 0
56  * on success.*/
57 int rtkit_make_high_priority(DBusConnection *system_bus, pid_t thread, int nice_level);
58 
59 /* Return the maximum value of realtime priority available. Realtime requests
60  * above this value will fail. A negative value is an errno style error code.
61  */
62 int rtkit_get_max_realtime_priority(DBusConnection *system_bus);
63 
64 /* Retrieve the minimum value of nice level available. High prio requests
65  * below this value will fail. The returned value is a negative errno
66  * style error code, or 0 on success.*/
67 int rtkit_get_min_nice_level(DBusConnection *system_bus, int* min_nice_level);
68 
69 /* Return the maximum value of RLIMIT_RTTIME to set before attempting a
70  * realtime request. A negative value is an errno style error code.
71  */
72 long long rtkit_get_rttime_usec_max(DBusConnection *system_bus);
73 
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif
80