Debian Codegraph @

src/pi_tests/pip_stress.c

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-2.0-or-latercxx . . $ `<file>/src/pi_tests/pip_stress.c`/
2 /*
3 Pip stress - Priority Inheritance with processes
4
5 Copyright (C) 2009, John Kacur <[email protected]>
6 */
7
8 /*
9 * This program demonstrates the technique of using priority inheritance (PI)
10 * mutexes with processes instead of threads.
11 * The way to do this is to obtain some shared memory - in this case with
12 * mmap that backs a pthread_mutex_t since this will support PI.
13 * Pay particular attention to how this is intialized to support processes.
14 * Function init_shared_pthread_mutex() does this by setting the
15 * pthread_mutexattr to PTHREAD_PROCESS_SHARED and the mutex protocol to
16 * PTHREAD_PRIO_INHERIT.
17 * In this program we purposely try to invoke a classic priority inversion.
18 * A low priority process grabs the mutex and does some work.
19 * A high priority process comes a long and is blocked since the mutex is taken.
20 * A medium priority process that doesn't require the mutex then takes the
21 * processor. Because the processes are restricted to one cpu, the low priority
22 * processes never makes any progress because the medium priority process
23 * runs in an infinite loop. This is a priority inversion because the
24 * medium priority process is running at the expensive of the high priority
25 * process. However, since we have used PRIO_INHERIT and are running on a
26 * machine that supports preemption, the high priority process will lend it's
27 * priority to the low priority process which will preempt the medium priority
28 * process. The low priority process will then release the mutex which the
29 * high priority process can obtain. When the high priority process gets to run
30 * it kills the medium priority process.
31 * The state structure keeps track of the progress. Although this program
32 * is set up to likely trigger an inversion, there is no guarantee that
33 * scheduling will make that happen. After the program completes it reports
34 * whether a priority inversion occurred or not. In either case this program
35 * demonstrates how to use priority inheritance mutexes with processes.
36 * In fact, you would be better off to avoid scenarios in which a priority
37 * inversion occurs if possible - this program tries to trigger them just
38 * to show that it works. If you are having difficulty triggering an inversion,
39 * merely increase the time that the low priority process sleeps while
40 * holding the lock. (usleep);
41 * Also note that you have to run as a user with permission to change
42 * scheduling priorities.
43 */
44
45 #include "pip_stress.h"cxx . . $ `<file>/src/include/pip_stress.h`/
46
47 #include <unistd.h>
48 #include <getopt.h>
49
50 /* default time for low priority thread usleep */
51 useconds_tcxx . . $ useconds_t# usleep_valcxx . . $ usleep_val. = 500;
52
53 pthread_mutex_tcxx . . $ pthread_mutex_t# *resourcecxx . . $ resource.;
54
55 /* This records the state to determine whether a priority inversion occurred */
56 struct Statecxx . . $ State# {
57 int low_owns_resourcecxx . . $ State#low_owns_resource.;
58 int high_startedcxx . . $ State#high_started.;
59 int high_owns_resourcecxx . . $ State#high_owns_resource.;
60 int medium_startedcxx . . $ State#medium_started.;
61 int inversioncxx . . $ State#inversion.;
62 pthread_mutex_tcxx . . $ pthread_mutex_t# *mutexcxx . . $ State#mutex.;
63 };
64
65 struct Statecxx . . $ State# *statepcxx . . $ statep.;
66
67 const int policycxx . . $ policy. = SCHED_FIFOcxx . . $ `<external>/4872883757279652994/sched.h:29:9`!;
68 static int prio_mincxx . . $ prio_min.; /* Initialized for the minimum priority of policy */
69
70 static void usagecxx . . $ usage(d4f767463ce0a6b3).(int error)
71 {
72 printfcxx . . $ printf(581fddd72a8db8fc).("pip_stress V %1.2f\n", VERSIONcxx . . $ `<built-in>:412:9`!);
73 printfcxx . . $ printf(581fddd72a8db8fc).("Usage:\n"
74 "pip_stress <options>\n"\
75 "-h --help Show this help menu.\n"\
76 "-u TIME --usleep=TIME Specify the sleep time in usec of the low priority process.\n"\
77 " Defaults to 500.\n"
78 );
79 exitcxx . . $ exit(3ca292c338df9bb3).(error);
80 }
81
82 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[])
83 {
84 void *mptr; /* memory pointer */
85 pid_tcxx . . $ pid_t# pid1, pid2;
86 cpu_set_tcxx . . $ cpu_set_t# set, *setp = &set;
87 int res;
88 int *minimum_priority = (int*)&prio_mincxx . . $ prio_min.;
89
90 for (;;) {
91 struct optioncxx . . $ option# long_options[] = {
92 { "help", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 'h' },
93 { "usleep", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 'u' },
94 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0 },
95 };
96
97 int c = getopt_longcxx . . $ getopt_long(41f665c090816971).(argc, argv, "hu:", long_options, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
98 if (c == -1)
99 break;
100 switch (c) {
101 case 'h':
102 usagecxx . . $ usage(d4f767463ce0a6b3).(0);
103 break;
104 case 'u':
105 usleep_valcxx . . $ usleep_val. = strtoulcxx . . $ strtoul(31746e8d6ec49860).(optargcxx . . $ optarg., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10);
106 break;
107 default:
108 usagecxx . . $ usage(d4f767463ce0a6b3).(1);
109 break;
110 };
111 }
112
113 *minimum_priority = sched_get_priority_mincxx . . $ sched_get_priority_min(7864480464b09eea).(policycxx . . $ policy.);
114
115 if (check_privscxx . . $ check_privs(b126dc7c1de90089).())
116 exitcxx . . $ exit(3ca292c338df9bb3).(1);
117
118 mptr = mmap_pagecxx . . $ mmap_page(50c7df7de5344ebb).(); /* Get a page of shared memory */
119 resourcecxx . . $ resource. = (pthread_mutex_tcxx . . $ pthread_mutex_t#*)mptr; /* point our lock to it */
120 mptr += sizeof(pthread_mutex_tcxx . . $ pthread_mutex_t#); /* advance the memory pointer */
121
122 /* Initialize our mutex via the resource pointer */
123 init_shared_pthread_mutexcxx . . $ init_shared_pthread_mutex(b3840a7275456684).(resourcecxx . . $ resource., PTHREAD_PRIO_INHERITcxx . . $ PTHREAD_PRIO_INHERIT.);
124
125 statepcxx . . $ statep. = (struct Statecxx . . $ State#*)mptr;
126 mptr += sizeof(struct Statecxx . . $ State#);
127
128 init_statecxx . . $ init_state(49f6e7a06ebc5aa8).(); /* Initialize the state structure */
129
130 statepcxx . . $ statep.->mutexcxx . . $ State#mutex. = (pthread_mutex_tcxx . . $ pthread_mutex_t#*)mptr; /* point the next lock to it */
131 mptr += sizeof(pthread_mutex_tcxx . . $ pthread_mutex_t#); /* advance the memory pointer */
132
133 /* Initialize our State mutex */
134 init_shared_pthread_mutexcxx . . $ init_shared_pthread_mutex(b3840a7275456684).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex., PTHREAD_PRIO_NONEcxx . . $ PTHREAD_PRIO_NONE.);
135
136 set_rt_priocxx . . $ set_rt_prio(2326284602b0bb2d).(0, prio_mincxx . . $ prio_min., policycxx . . $ policy.);
137
138 /* We restrict this program to the first cpu, inorder to increase
139 * the likelihood of a priority inversion */
140 CPU_ZEROcxx . . $ `<external>/17522079545615609418/sched.h:96:10`!(setp);
141 CPU_SETcxx . . $ `<external>/17522079545615609418/sched.h:92:10`!(0, setp);
142 res = sched_setaffinitycxx . . $ sched_setaffinity(48631566441f33fb).(0, sizeof(set), setp);
143 if (res == -1) {
144 int err = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
145 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("sched_setaffinity: ");
146 err_exitcxx . . $ err_exit(7cbaebca1c50800).(err, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
147 }
148
149 pid1 = forkcxx . . $ fork(b126dc7c1de90089).();
150 if (pid1 == -1) {
151 perrorcxx . . $ perror(85c52e162fed56f9).("fork");
152 exitcxx . . $ exit(3ca292c338df9bb3).(1);
153 } else if (pid1 != 0) { /* parent code */
154 lowcxx . . $ low(d4f767463ce0a6b3).(pid1);
155 } else { /* child code */
156 pid2 = forkcxx . . $ fork(b126dc7c1de90089).(); /* parent code */
157 if (pid2 == -1) {
158 perrorcxx . . $ perror(85c52e162fed56f9).("fork: ");
159 exitcxx . . $ exit(3ca292c338df9bb3).(1);
160 } else if (pid2 != 0) { /* parent code */
161 highcxx . . $ high(d4f767463ce0a6b3).(pid2);
162 } else { /* child code */
163 mediumcxx . . $ medium(49f6e7a06ebc5aa8).();
164 }
165 }
166
167 exitcxx . . $ exit(3ca292c338df9bb3).(0);
168 }
169
170 /* Initialize the structure that tracks when a priority inversion occurs */
171 void init_statecxx . . $ init_state(49f6e7a06ebc5aa8).(void)
172 {
173 /* Init the State structure */
174 statepcxx . . $ statep.->low_owns_resourcecxx . . $ State#low_owns_resource. = 0;
175 statepcxx . . $ statep.->high_startedcxx . . $ State#high_started. = 0;
176 statepcxx . . $ statep.->high_owns_resourcecxx . . $ State#high_owns_resource. = 0;
177 statepcxx . . $ statep.->medium_startedcxx . . $ State#medium_started. = 0;
178 /* Assume an inversion will occur until proven false */
179 statepcxx . . $ statep.->inversioncxx . . $ State#inversion. = 1;
180 }
181
182 /* @pid = high priority process pid */
183 void lowcxx . . $ low(d4f767463ce0a6b3).(pid_tcxx . . $ pid_t# pid)
184 {
185 int status;
186 Pthread_mutex_lockcxx . . $ Pthread_mutex_lock(4f83bfebf4bb9c8b).(resourcecxx . . $ resource.);
187 Pthread_mutex_lockcxx . . $ Pthread_mutex_lock(4f83bfebf4bb9c8b).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex.);
188 statepcxx . . $ statep.->low_owns_resourcecxx . . $ State#low_owns_resource. = 1;
189 if (statepcxx . . $ statep.->high_owns_resourcecxx . . $ State#high_owns_resource. ||
190 statepcxx . . $ statep.->medium_startedcxx . . $ State#medium_started.) {
191 statepcxx . . $ statep.->inversioncxx . . $ State#inversion. = 0;
192 }
193 Pthread_mutex_unlockcxx . . $ Pthread_mutex_unlock(4f83bfebf4bb9c8b).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex.);
194 usleepcxx . . $ usleep(4c679297bf94b9eb).(usleep_valcxx . . $ usleep_val.);
195 Pthread_mutex_unlockcxx . . $ Pthread_mutex_unlock(4f83bfebf4bb9c8b).(resourcecxx . . $ resource.);
196 waitpidcxx . . $ waitpid(1df93256b606fe1f).(pid, &status, 0);
197 }
198
199 void mediumcxx . . $ medium(49f6e7a06ebc5aa8).(void)
200 {
201 set_rt_priocxx . . $ set_rt_prio(2326284602b0bb2d).(0, prio_mincxx . . $ prio_min.+1, policycxx . . $ policy.);
202 Pthread_mutex_lockcxx . . $ Pthread_mutex_lock(4f83bfebf4bb9c8b).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex.);
203 statepcxx . . $ statep.->medium_startedcxx . . $ State#medium_started. = 1;
204 if (!statepcxx . . $ statep.->high_startedcxx . . $ State#high_started.)
205 statepcxx . . $ statep.->inversioncxx . . $ State#inversion. = 0;
206 Pthread_mutex_unlockcxx . . $ Pthread_mutex_unlock(4f83bfebf4bb9c8b).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex.);
207
208 for(;;); /* infinite loop */
209 }
210
211 /* @pid = medium priority process pid */
212 void highcxx . . $ high(d4f767463ce0a6b3).(pid_tcxx . . $ pid_t# pid)
213 {
214 int status;
215 set_rt_priocxx . . $ set_rt_prio(2326284602b0bb2d).(0, prio_mincxx . . $ prio_min.+2, policycxx . . $ policy.);
216
217 /* Must come after raising the priority */
218 Pthread_mutex_lockcxx . . $ Pthread_mutex_lock(4f83bfebf4bb9c8b).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex.);
219 statepcxx . . $ statep.->high_startedcxx . . $ State#high_started. = 1;
220 Pthread_mutex_unlockcxx . . $ Pthread_mutex_unlock(4f83bfebf4bb9c8b).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex.);
221
222 Pthread_mutex_lockcxx . . $ Pthread_mutex_lock(4f83bfebf4bb9c8b).(resourcecxx . . $ resource.);
223 Pthread_mutex_lockcxx . . $ Pthread_mutex_lock(4f83bfebf4bb9c8b).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex.);
224 statepcxx . . $ statep.->high_owns_resourcecxx . . $ State#high_owns_resource. = 1;
225 if (!statepcxx . . $ statep.->low_owns_resourcecxx . . $ State#low_owns_resource. || !statepcxx . . $ statep.->medium_startedcxx . . $ State#medium_started.)
226 statepcxx . . $ statep.->inversioncxx . . $ State#inversion. = 0;
227 Pthread_mutex_unlockcxx . . $ Pthread_mutex_unlock(4f83bfebf4bb9c8b).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex.);
228 Pthread_mutex_unlockcxx . . $ Pthread_mutex_unlock(4f83bfebf4bb9c8b).(resourcecxx . . $ resource.);
229 killcxx . . $ kill(9b79fb6aee4c0440).(pid, SIGKILLcxx . . $ `<external>/11773118241360591791/signum-generic.h:59:9`!); /* kill the medium thread */
230 waitpidcxx . . $ waitpid(1df93256b606fe1f).(pid, &status, 0);
231
232 Pthread_mutex_lockcxx . . $ Pthread_mutex_lock(4f83bfebf4bb9c8b).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex.);
233
234 if (statepcxx . . $ statep.->inversioncxx . . $ State#inversion.)
235 printfcxx . . $ printf(581fddd72a8db8fc).("Successfully used priority inheritance to handle an inversion\n");
236 else
237 printfcxx . . $ printf(581fddd72a8db8fc).("No inversion incurred\n");
238 Pthread_mutex_unlockcxx . . $ Pthread_mutex_unlock(4f83bfebf4bb9c8b).(statepcxx . . $ statep.->mutexcxx . . $ State#mutex.);
239 }
240
241 /* mmap a page of anonymous shared memory */
242 void *mmap_pagecxx . . $ mmap_page(50c7df7de5344ebb).(void)
243 {
244 void *mptr;
245 long pgsize = sysconfcxx . . $ sysconf(dc1f09c09fbff20f).(_SC_PAGE_SIZEcxx . . $ `<external>/6393649343499073842/confname.h:135:9`!);
246
247 mptr = mmapcxx . . $ mmap(ff06c1c904cdf0e2).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, pgsize, PROTRWcxx . . $ `src/include/pip_stress.h:39:9`!, MMAP_FLAGScxx . . $ `src/include/pip_stress.h:40:9`!, 0, 0);
248 if (mptr == MAP_FAILEDcxx . . $ `<external>/6724834311684550606/mman.h:44:9`!) {
249 perrorcxx . . $ perror(85c52e162fed56f9).("In function mmap_page - mmap");
250 exitcxx . . $ exit(3ca292c338df9bb3).(1);
251 }
252
253 return mptr;
254 }
255
256 long process_shared_mutex_availablecxx . . $ process_shared_mutex_available(da6335ded91d79c2).(void)
257 {
258 long res = -1; /* undefined */
259 #ifdef _POSIX_THREAD_PROCESS_SHAREDcxx . . $ `<external>/4533468968537266721/posix_opt.h:161:9`!
260 res = sysconfcxx . . $ sysconf(dc1f09c09fbff20f).(_SC_THREAD_PROCESS_SHAREDcxx . . $ `<external>/6393649343499073842/confname.h:248:9`!);
261 if (res == -1) {
262 int err = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!; /* save the error number */
263 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("%s: sysconf(_SC_THREAD_PROCESS_SHARED): ", __func__);
264 err_exitcxx . . $ err_exit(7cbaebca1c50800).(err, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
265 }
266 #else
267 #error _POSIX_THREAD_PROCESS_SHARED is not defined
268 #endif
269 return res;
270 }
271
272 void Pthread_mutexattr_initcxx . . $ Pthread_mutexattr_init(8897c885d8ee1039).(pthread_mutexattr_tcxx . . $ pthread_mutexattr_t# *attr)
273 {
274 int err;
275 err = pthread_mutexattr_initcxx . . $ pthread_mutexattr_init(7099fa328d29ec1).(attr);
276 if (err) {
277 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("%s: pthread_mutexattr_init(): ", __func__);
278 err_exitcxx . . $ err_exit(7cbaebca1c50800).(err, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
279 }
280 }
281
282 void Pthread_mutexattr_setpsharedcxx . . $ Pthread_mutexattr_setpshared(9eb95a6600ee7d50).(pthread_mutexattr_tcxx . . $ pthread_mutexattr_t# *attr, int pshared)
283 {
284 int err;
285 err = pthread_mutexattr_setpsharedcxx . . $ pthread_mutexattr_setpshared(490643a50482da1c).(attr, pshared);
286 if (err) {
287 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("%s: pthread_mutexattr_setpshared(): ", __func__);
288 err_exitcxx . . $ err_exit(7cbaebca1c50800).(err, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
289 }
290 }
291
292 void Pthread_mutexattr_setprotocolcxx . . $ Pthread_mutexattr_setprotocol(9eb95a6600ee7d50).(pthread_mutexattr_tcxx . . $ pthread_mutexattr_t# *attr, int protocol)
293 {
294 int err;
295 err = pthread_mutexattr_setprotocolcxx . . $ pthread_mutexattr_setprotocol(490643a50482da1c).(attr, protocol);
296 if (err) {
297 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("%s: pthread_mutexattr_setprotocol(): ", __func__);
298 err_exitcxx . . $ err_exit(7cbaebca1c50800).(err, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
299 }
300 }
301
302 void Pthread_mutex_initcxx . . $ Pthread_mutex_init(c71919e603de4103).(pthread_mutex_tcxx . . $ pthread_mutex_t# *mutex, pthread_mutexattr_tcxx . . $ pthread_mutexattr_t# *attr)
303 {
304 int err;
305 err = pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(mutex, attr);
306 if (err) {
307 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("%s: pthread_mutex_init(): ", __func__);
308 err_exitcxx . . $ err_exit(7cbaebca1c50800).(err, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
309 }
310 }
311
312 void Pthread_mutex_lockcxx . . $ Pthread_mutex_lock(4f83bfebf4bb9c8b).(pthread_mutex_tcxx . . $ pthread_mutex_t# *mutex)
313 {
314 int err;
315 err = pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(mutex);
316 if (err) {
317 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("%s: pthread_mutex_lock(): ", __func__);
318 err_exitcxx . . $ err_exit(7cbaebca1c50800).(err, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
319 }
320 }
321
322 void Pthread_mutex_unlockcxx . . $ Pthread_mutex_unlock(4f83bfebf4bb9c8b).(pthread_mutex_tcxx . . $ pthread_mutex_t# *mutex)
323 {
324 int err;
325 err = pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(mutex);
326 if (err) {
327 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("%s: pthread_mutex_unlock(): ", __func__);
328 err_exitcxx . . $ err_exit(7cbaebca1c50800).(err, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
329 }
330 }
331
332 void init_shared_pthread_mutexcxx . . $ init_shared_pthread_mutex(b3840a7275456684).(pthread_mutex_tcxx . . $ pthread_mutex_t# *mutex, int protocol)
333 {
334 pthread_mutexattr_tcxx . . $ pthread_mutexattr_t# attr;
335
336 process_shared_mutex_availablecxx . . $ process_shared_mutex_available(da6335ded91d79c2).();
337
338 Pthread_mutexattr_initcxx . . $ Pthread_mutexattr_init(8897c885d8ee1039).(&attr);
339 Pthread_mutexattr_setpsharedcxx . . $ Pthread_mutexattr_setpshared(9eb95a6600ee7d50).(&attr, PTHREAD_PROCESS_SHAREDcxx . . $ `<external>/14712363683955484316/pthread.h:149:9`!);
340 Pthread_mutexattr_setprotocolcxx . . $ Pthread_mutexattr_setprotocol(9eb95a6600ee7d50).(&attr, protocol);
341
342 Pthread_mutex_initcxx . . $ Pthread_mutex_init(c71919e603de4103).(mutex, &attr);
343 }
344
345 /* Set the priority and policy of a process */
346 int set_rt_priocxx . . $ set_rt_prio(2326284602b0bb2d).(pid_tcxx . . $ pid_t# pid, int prio, int policy)
347 {
348 int err;
349 struct sched_paramcxx . . $ sched_param# param;
350 struct sched_paramcxx . . $ sched_param# *pparam = &param;
351 pparam->sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`! = prio;
352 err = sched_setschedulercxx . . $ sched_setscheduler(b99e0841b006542f).(pid, policy, pparam);
353 if (err) {
354 err = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!; /* save the errno */
355 err_msg_ncxx . . $ err_msg_n(26800c7917ec8ef2).(err, "%s: sched_setscheduler(): ", __func__);
356 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("%s: prio = %d\n", __func__, prio);
357 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("%s: pparam->sched_priority = %d\n", __func__, pparam->sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`!);
358 err_msgcxx . . $ err_msg(d5d9ff45db7b5d36).("%s: policy = %d\n", __func__, policy);
359 }
360 return err; /* 0 on success */
361 }
362
363 int get_rt_priocxx . . $ get_rt_prio(7864480464b09eea).(pid_tcxx . . $ pid_t# pid)
364 {
365 int err;
366 struct sched_paramcxx . . $ sched_param# param;
367 err = sched_getparamcxx . . $ sched_getparam(434f53043d3e31ba).(pid, &param);
368 if (err) {
369 err = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!; /* save the errno */
370 err_msg_ncxx . . $ err_msg_n(26800c7917ec8ef2).(err, "%s: get_rt_prio(): ", __func__);
371 return -1;
372 }
373 return param.sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`!;
374 }