1 /* Copyright (C) 2006 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 #include <sys/syscall.h>
29 /* This test is Linux specific. */
30 #define CHECK_TPP_PRIORITY(normal, boosted) \
33 pid_t tid = syscall (__NR_gettid); \
35 struct sched_param cep_sp; \
37 if (pthread_getschedparam (pthread_self (), &cep_policy, \
40 puts ("getschedparam failed"); \
43 else if (cep_sp.sched_priority != (normal)) \
45 printf ("unexpected priority %d != %d\n", \
46 cep_sp.sched_priority, (normal)); \
48 if (syscall (__NR_sched_getparam, tid, &cep_sp) == 0 \
49 && cep_sp.sched_priority != (boosted)) \
51 printf ("unexpected boosted priority %d != %d\n", \
52 cep_sp.sched_priority, (boosted)); \
58 int fifo_min
, fifo_max
;
63 fifo_min
= sched_get_priority_min (SCHED_FIFO
);
66 printf ("couldn't get min priority for SCHED_FIFO: %m\n");
70 fifo_max
= sched_get_priority_max (SCHED_FIFO
);
73 printf ("couldn't get max priority for SCHED_FIFO: %m\n");
77 if (fifo_min
> 4 || fifo_max
< 10)
79 printf ("%d..%d SCHED_FIFO priority interval not suitable for this test\n",
84 struct sched_param sp
;
85 memset (&sp
, 0, sizeof (sp
));
86 sp
.sched_priority
= 4;
87 int e
= pthread_setschedparam (pthread_self (), SCHED_FIFO
, &sp
);
91 printf ("cannot set scheduling params: %m\n");