Write a program that demonstrates the use of nice() system call. After a child process is started using fork(), assign higher priority to the child using nice() system call.
#include<stdio.h>
#include<unistd.h>
int main()
{
int pid,retnice;
printf("Press DEL to stop process\n");
pid=fork();
for(;;)
{
if (pid==0)
{
retnice=nice(-5);
printf("Child gets higher CPU priority %d \n",retnice);
sleep(1);
}
else
{
retnice=nice(4);
printf("Parent gets lower CPU priority %d \n",retnice);
sleep(1);
}
}
}
Comments
Post a Comment