
214 Embedded Linux System Design and Development
Listing 7.1 Process Scheduling Operations
/* sched.c */
#include <sched.h>
int main(){
struct sched_param param, new_param;
/*
* A process starts with the default policy SCHED_OTHER unless
* spawned by a SCHED_RR or SCHED_FIFO process.
*/
printf("start policy = %d\n", sched_getscheduler(0));
/*
* output -> start policy = 0 .
* (For SCHED_FIFO or SCHED_RR policies, sched_getscheduler
* returns 1 and 2 respectively
*/
/*
* Create a SCHED_FIFO process running with average priority
*/
param.sched_priority = (sched_get_priority_min(SCHED_FIFO) +
sched_get_priority_max(SCHED_FIFO))/2;
printf("max ...