1 /* Copyright (C) 2006-2022 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
25 #include <sys/syscall.h>
27 /* This test is Linux specific. */
28 #define CHECK_TPP_PRIORITY(normal, boosted) \
31 pid_t tid = syscall (__NR_gettid); \
33 struct sched_param cep_sp; \
35 if (pthread_getschedparam (pthread_self (), &cep_policy, \
38 puts ("getschedparam failed"); \
41 else if (cep_sp.sched_priority != (normal)) \
43 printf ("unexpected priority %d != %d\n", \
44 cep_sp.sched_priority, (normal)); \
46 if (syscall (__NR_sched_getparam, tid, &cep_sp) == 0 \
47 && cep_sp.sched_priority != (boosted)) \
49 printf ("unexpected boosted priority %d != %d\n", \
50 cep_sp.sched_priority, (boosted)); \
56 int fifo_min
, fifo_max
;
61 fifo_min
= sched_get_priority_min (SCHED_FIFO
);
64 printf ("couldn't get min priority for SCHED_FIFO: %m\n");
68 fifo_max
= sched_get_priority_max (SCHED_FIFO
);
71 printf ("couldn't get max priority for SCHED_FIFO: %m\n");
75 if (fifo_min
> 4 || fifo_max
< 10)
77 printf ("%d..%d SCHED_FIFO priority interval not suitable for this test\n",
82 struct sched_param sp
;
83 memset (&sp
, 0, sizeof (sp
));
84 sp
.sched_priority
= 4;
85 int e
= pthread_setschedparam (pthread_self (), SCHED_FIFO
, &sp
);
89 printf ("cannot set scheduling params: %m\n");