]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
3a54a157 ZJS |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
0307f791 | 4 | <!-- SPDX-License-Identifier: LGPL-2.1+ --> |
dc83f27a LP |
5 | |
6 | <refentry id="sd_event_source_set_priority" xmlns:xi="http://www.w3.org/2001/XInclude"> | |
7 | ||
8 | <refentryinfo> | |
9 | <title>sd_event_source_set_priority</title> | |
10 | <productname>systemd</productname> | |
dc83f27a LP |
11 | </refentryinfo> |
12 | ||
13 | <refmeta> | |
14 | <refentrytitle>sd_event_source_set_priority</refentrytitle> | |
15 | <manvolnum>3</manvolnum> | |
16 | </refmeta> | |
17 | ||
18 | <refnamediv> | |
19 | <refname>sd_event_source_set_priority</refname> | |
20 | <refname>sd_event_source_get_priority</refname> | |
21 | <refname>SD_EVENT_PRIORITY_IMPORTANT</refname> | |
22 | <refname>SD_EVENT_PRIORITY_NORMAL</refname> | |
23 | <refname>SD_EVENT_PRIORITY_IDLE</refname> | |
24 | ||
25 | <refpurpose>Set or retrieve the priority of event sources</refpurpose> | |
26 | </refnamediv> | |
27 | ||
28 | <refsynopsisdiv> | |
29 | <funcsynopsis> | |
30 | <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo> | |
31 | ||
32 | <funcsynopsisinfo><token>enum</token> { | |
f2e5f466 ME |
33 | <constant>SD_EVENT_PRIORITY_IMPORTANT</constant> = -100, |
34 | <constant>SD_EVENT_PRIORITY_NORMAL</constant> = 0, | |
35 | <constant>SD_EVENT_PRIORITY_IDLE</constant> = 100, | |
dc83f27a LP |
36 | };</funcsynopsisinfo> |
37 | ||
38 | <funcprototype> | |
39 | <funcdef>int <function>sd_event_source_set_priority</function></funcdef> | |
40 | <paramdef>sd_event_source *<parameter>source</parameter></paramdef> | |
41 | <paramdef>int64_t <parameter>priority</parameter></paramdef> | |
42 | </funcprototype> | |
43 | ||
44 | <funcprototype> | |
45 | <funcdef>int <function>sd_event_source_get_priority</function></funcdef> | |
46 | <paramdef>sd_event_source *<parameter>source</parameter></paramdef> | |
47 | <paramdef>int64_t *<parameter>priority</parameter></paramdef> | |
48 | </funcprototype> | |
49 | ||
50 | </funcsynopsis> | |
51 | </refsynopsisdiv> | |
52 | ||
53 | <refsect1> | |
54 | <title>Description</title> | |
55 | ||
56 | <para><function>sd_event_source_set_priority()</function> may be | |
57 | used to set the priority for the event source object specified as | |
58 | <parameter>source</parameter>. The priority is specified as an | |
59 | arbitrary signed 64bit integer. The priority is initialized to | |
60 | <constant>SD_EVENT_PRIORITY_NORMAL</constant> (0) when the event | |
61 | source is allocated with a call such as | |
62 | <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
63 | or | |
64 | <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
65 | and may be changed with this call. If multiple event sources have seen events at the same time, they are dispatched in the order indicated by the | |
66 | event sources' priorities. Event sources with smaller priority | |
67 | values are dispatched first. As well-known points of reference, | |
68 | the constants <constant>SD_EVENT_PRIORITY_IMPORTANT</constant> | |
69 | (-100), <constant>SD_EVENT_PRIORITY_NORMAL</constant> (0) and | |
70 | <constant>SD_EVENT_PRIORITY_IDLE</constant> (100) may be used to | |
71 | indicate event sources that shall be dispatched early, normally or | |
72 | late. It is recommended to specify priorities based on these | |
ccddd104 | 73 | definitions, and relative to them — however, the full 64bit |
dc83f27a LP |
74 | signed integer range is available for ordering event |
75 | sources.</para> | |
76 | ||
77 | <para>Priorities define the order in which event sources that have | |
78 | seen events are dispatched. Care should be taken to ensure that | |
79 | high-priority event sources (those with negative priority values | |
80 | assigned) do not cause starvation of low-priority event sources | |
81 | (those with positive priority values assigned).</para> | |
82 | ||
83 | <para>The order in which event sources with the same priority are | |
84 | dispatched is undefined, but the event loop generally tries to | |
85 | dispatch them in the order it learnt about events on them. As the | |
86 | backing kernel primitives do not provide accurate information | |
7f3fdb7f | 87 | about the order in which events occurred this is not necessarily |
dc83f27a LP |
88 | reliable. However, it is guaranteed that if events are seen on |
89 | multiple same-priority event sources at the same time, each one is | |
90 | not dispatched again until all others have been dispatched | |
2dd67817 | 91 | once. This behavior guarantees that within each priority |
dc83f27a LP |
92 | particular event sources do not starve or dominate the event |
93 | loop.</para> | |
94 | ||
1eb54dc6 LP |
95 | <para>The priority of event sources may be changed at any time of their lifetime, with the exception of inotify |
96 | event sources (i.e. those created with | |
97 | <citerefentry><refentrytitle>sd_event_add_inotify</refentrytitle><manvolnum>3</manvolnum></citerefentry>) whose | |
98 | priority may only be changed in the time between their initial creation and the first subsequent event loop | |
99 | iteration.</para> | |
100 | ||
dc83f27a LP |
101 | <para><function>sd_event_source_get_priority()</function> may be |
102 | used to query the current priority assigned to the event source | |
103 | object <parameter>source</parameter>.</para> | |
104 | </refsect1> | |
105 | ||
106 | <refsect1> | |
107 | <title>Return Value</title> | |
108 | ||
b1de39de ZJS |
109 | <para>On success, <function>sd_event_source_set_priority()</function> and |
110 | <function>sd_event_source_get_priority()</function> return a non-negative integer. On failure, they | |
111 | return a negative errno-style error code.</para> | |
dc83f27a | 112 | |
b1de39de ZJS |
113 | <refsect2> |
114 | <title>Errors</title> | |
dc83f27a | 115 | |
b1de39de | 116 | <para>Returned errors may indicate the following problems:</para> |
dc83f27a | 117 | |
b1de39de ZJS |
118 | <variablelist> |
119 | <varlistentry> | |
120 | <term><constant>-EINVAL</constant></term> | |
dc83f27a | 121 | |
b1de39de ZJS |
122 | <listitem><para><parameter>source</parameter> is not a valid pointer to an |
123 | <structname>sd_event_source</structname> object.</para></listitem> | |
124 | </varlistentry> | |
dc83f27a | 125 | |
b1de39de ZJS |
126 | <varlistentry> |
127 | <term><constant>-ENOMEM</constant></term> | |
dc83f27a | 128 | |
b1de39de ZJS |
129 | <listitem><para>Not enough memory.</para></listitem> |
130 | </varlistentry> | |
dc83f27a | 131 | |
b1de39de ZJS |
132 | <varlistentry> |
133 | <term><constant>-ESTALE</constant></term> | |
dc83f27a | 134 | |
b1de39de | 135 | <listitem><para>The event loop is already terminated.</para></listitem> |
dc83f27a | 136 | |
b1de39de | 137 | </varlistentry> |
dc83f27a | 138 | |
b1de39de ZJS |
139 | <varlistentry> |
140 | <term><constant>-ECHILD</constant></term> | |
dc83f27a | 141 | |
b1de39de | 142 | <listitem><para>The event loop has been created in a different process.</para></listitem> |
dc83f27a | 143 | |
b1de39de | 144 | </varlistentry> |
dc83f27a | 145 | |
b1de39de ZJS |
146 | </variablelist> |
147 | </refsect2> | |
dc83f27a LP |
148 | </refsect1> |
149 | ||
150 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
151 | ||
152 | <refsect1> | |
153 | <title>See Also</title> | |
154 | ||
155 | <para> | |
156 | <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
157 | <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
158 | <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
dc83f27a | 159 | <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
8274a30d LP |
160 | <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
161 | <citerefentry><refentrytitle>sd_event_add_inotify</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
dc83f27a LP |
162 | <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
163 | </para> | |
164 | </refsect1> | |
165 | ||
166 | </refentry> |