tests: add SCHED_BATCH test
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=741090 Acked-by:: Jaromir Capik <jcapik@redhat.com> Acked-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
This commit is contained in:
committed by
Sami Kerola
parent
3c2377ca15
commit
23d2e0b0b7
39
testsuite/ps.test/test-schedbatch.c
Normal file
39
testsuite/ps.test/test-schedbatch.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/* test-schedbatch.c - Create a process using SCHED_BATCH scheduler
|
||||
* policy and nice value.
|
||||
* Compile: gcc -o test-schedbatch -Wall test-schedbatch.c
|
||||
* Usage: ./test-schedbatch [ <NICE> ]
|
||||
*
|
||||
* Author: Mike Fleetwood
|
||||
* https://bugzilla.redhat.com/show_bug.cgi?id=741090
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sched.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
int nice = 19;
|
||||
struct sched_param sp;
|
||||
char msg[50];
|
||||
|
||||
if (argc >= 2) {
|
||||
nice = atoi(argv[1]);
|
||||
}
|
||||
sp.sched_priority = 0;
|
||||
if (sched_setscheduler(0, SCHED_BATCH, &sp)) {
|
||||
perror("sched_setscheduler(0,SCHED_BATCH,{.sched_priority=0}");
|
||||
}
|
||||
if (setpriority(PRIO_PROCESS, 0, nice) || errno) {
|
||||
(void)snprintf(msg, sizeof(msg),
|
||||
"setpriority(PRIO_PROCESS, 0, %d)", nice);
|
||||
perror(msg);
|
||||
}
|
||||
while (1) {
|
||||
getchar();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user