Real time application programming - sched_setattr() fails if I set CPU affinity using sched_setaffinity().
Hello,
Working on a real time application, Getting runtime error at sched_setattr as "Operation Not permitted".Running on Ubuntu 16.04 LTS (4.4.0-97-generic kernel, x86_64 platform)
C program code excerpt as below:
unsigned int flags = 0;
sched_getattr(0, &attr, sizeof (struct sched_attr), 0);
if (ret != 0)
perror("getattr failed:");
attr.sched_policy = SCHED_DEADLINE;
attr.sched_runtime = 5 * 100 * 1000;
attr.sched_deadline = 8 * 100 * 1000;
attr.sched_period = 10 * 100 * 1000;
attr.size = sizeof (attr);
attr.sched_flags = 0;
attr.sched_nice = 0;
attr.sched_priority = 0;
if(sched_setaffinity(0,sizeof(set), &set) < 0)
{
perror("sched_setaffinity :");
return 0;
}
ret = sched_setattr(0, &attr, flags);
if(ret!=0)
{
perror("sched_setattr failed: ");
}
But, If I comment the sched_setaffinity() call, it runs without error. Also, using SCHED_FIFO by calling sched_setscheduler() doesn't give me any error after setting CPU affinity. Only the combination of sched_setaffinity with sched_setattr() generates error. I am running in sudo mode.
Thanks in advance,
Bhargav
|