#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <errno.h>

void get_prio(void)
{
	int ret;
	int policy;
	struct sched_param param;

	policy = sched_getscheduler(0);
	printf("policy = %d\n", policy);

	ret = sched_getparam(0, &param);
	if (ret == 0) {
		printf("sched_priority = %d\n", param.sched_priority);
	}
	else {
		perror("sched_getparam");
	}
}

void set_prio(int prio)
{
	int ret;
	struct sched_param param;

	param.sched_priority = prio;
	ret = sched_setscheduler(0, SCHED_RR, &param);
	if (ret != 0) {
		perror("sched_setscheduler");
	}
}

int main(int argc, char **argv)
{
	set_prio(1);
	get_prio();

	/* キー入力待ち */
	getchar();

	set_prio(99);
	get_prio();

	/* キー入力待ち */
	getchar();

	return 0;
}
