1
/* $Id: syscall_setscheduler.c 61 2006-05-19 18:32:14Z steve-beattie $ */
4
* Copyright (C) 2002-2005 Novell/SUSE
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License as
8
* published by the Free Software Foundation, version 2 of the
12
/* test whether the sched_setscheduler(2) syscall is allowed. */
21
main (int argc, char * argv[]) {
22
struct sched_param sp, saved_sp, new_sp;
23
int saved_sched_policy, new_sched_policy;
25
/* save the default policy and priority */
26
memset(&saved_sp, 0, sizeof(saved_sp));
27
saved_sched_policy = sched_getscheduler(0);
28
if (saved_sched_policy < 0) {
29
perror ("FAIL: Couldn't get scheduler policy\n");
30
saved_sched_policy = SCHED_OTHER;
33
saved_sp.sched_priority = sched_get_priority_max(saved_sched_policy);
35
memset(&sp, 0, sizeof(sp));
36
sp.sched_priority = sched_get_priority_max(SCHED_RR) - 1;
37
if (sched_setscheduler(0, SCHED_RR, &sp)) {
38
perror("FAIL: Can't set SCHED_RR");
42
memset(&new_sp, 0, sizeof(new_sp));
43
new_sched_policy = sched_getscheduler(0);
44
if (new_sched_policy != SCHED_RR) {
45
fprintf (stderr, "FAIL: set policy is %d, not SCHED_RR\n",