Dmitry V. Levin
9f6611bb31
Automatically change tests/*.c files using the following sed regexp: sed -i 's/errno == E[[:alnum:]]\+ ? "E[[:alnum:]]\+" : "E[[:alnum:]]\+"/errno2name()/g'
65 lines
1.3 KiB
C
65 lines
1.3 KiB
C
#include "tests.h"
|
|
#include <sys/syscall.h>
|
|
|
|
#if defined __NR_sched_getscheduler && defined __NR_sched_setscheduler
|
|
|
|
# include <errno.h>
|
|
# include <sched.h>
|
|
# include <stdio.h>
|
|
# include <unistd.h>
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
struct sched_param *const param = tail_alloc(sizeof(struct sched_param));
|
|
int rc = syscall(__NR_sched_getscheduler, 0);
|
|
const char *scheduler;
|
|
switch (rc) {
|
|
case SCHED_FIFO:
|
|
scheduler = "SCHED_FIFO";
|
|
break;
|
|
case SCHED_RR:
|
|
scheduler = "SCHED_RR";
|
|
break;
|
|
# ifdef SCHED_BATCH
|
|
case SCHED_BATCH:
|
|
scheduler = "SCHED_BATCH";
|
|
break;
|
|
# endif
|
|
# ifdef SCHED_IDLE
|
|
case SCHED_IDLE:
|
|
scheduler = "SCHED_IDLE";
|
|
break;
|
|
# endif
|
|
# ifdef SCHED_ISO
|
|
case SCHED_ISO:
|
|
scheduler = "SCHED_ISO";
|
|
break;
|
|
# endif
|
|
# ifdef SCHED_DEADLINE
|
|
case SCHED_DEADLINE:
|
|
scheduler = "SCHED_DEADLINE";
|
|
break;
|
|
# endif
|
|
default:
|
|
scheduler = "SCHED_OTHER";
|
|
}
|
|
printf("sched_getscheduler(0) = %d (%s)\n",
|
|
rc, scheduler);
|
|
|
|
param->sched_priority = -1;
|
|
rc = syscall(__NR_sched_setscheduler, 0, SCHED_FIFO, param);
|
|
printf("sched_setscheduler(0, SCHED_FIFO, [%d]) = %d %s (%m)\n",
|
|
param->sched_priority, rc,
|
|
errno2name());
|
|
|
|
puts("+++ exited with 0 +++");
|
|
return 0;
|
|
}
|
|
|
|
#else
|
|
|
|
SKIP_MAIN_UNDEFINED("__NR_sched_getscheduler && __NR_sched_setscheduler")
|
|
|
|
#endif
|