1 /* Copyright (C) 2006-2021 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
26 #include <sys/syscall.h>
28 /* This test is Linux specific. */
29 #define CHECK_TPP_PRIORITY(normal, boosted) \
32 pid_t tid = syscall (__NR_gettid); \
34 struct sched_param cep_sp; \
36 if (pthread_getschedparam (pthread_self (), &cep_policy, \
39 puts ("getschedparam failed"); \
42 else if (cep_sp.sched_priority != (normal)) \
44 printf ("unexpected priority %d != %d\n", \
45 cep_sp.sched_priority, (normal)); \
47 if (syscall (__NR_sched_getparam, tid, &cep_sp) == 0 \
48 && cep_sp.sched_priority != (boosted)) \
50 printf ("unexpected boosted priority %d != %d\n", \
51 cep_sp.sched_priority, (boosted)); \
57 int fifo_min
, fifo_max
;
62 fifo_min
= sched_get_priority_min (SCHED_FIFO
);
65 printf ("couldn't get min priority for SCHED_FIFO: %m\n");
69 fifo_max
= sched_get_priority_max (SCHED_FIFO
);
72 printf ("couldn't get max priority for SCHED_FIFO: %m\n");
76 if (fifo_min
> 4 || fifo_max
< 10)
78 printf ("%d..%d SCHED_FIFO priority interval not suitable for this test\n",
83 struct sched_param sp
;
84 memset (&sp
, 0, sizeof (sp
));
85 sp
.sched_priority
= 4;
86 int e
= pthread_setschedparam (pthread_self (), SCHED_FIFO
, &sp
);
90 printf ("cannot set scheduling params: %m\n");