LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-17-2017, 06:07 AM   #1
barz_83_LQ
Member
 
Registered: Apr 2017
Posts: 31

Rep: Reputation: Disabled
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
 
Old 11-20-2017, 08:23 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,287

Rep: Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393
would be nice to see what kind of error was generated....
 
Old 11-20-2017, 10:11 AM   #3
barz_83_LQ
Member
 
Registered: Apr 2017
Posts: 31

Original Poster
Rep: Reputation: Disabled
The error is:
sched_setattr failed : Operation not permitted

This corresponds to return error code of sched_setattr() : EPERM

Thank you
 
  


Reply

Tags
attribute, cpuaffinity, realtime, scheduler


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set cpu affinity to all the tasks maheshajja Linux - Kernel 2 02-11-2015 09:19 AM
LXer: How to Change CPU Affinity of CPU Intensive Multithreaded Applications (Ubuntu) LXer Syndicated Linux News 0 12-10-2012 12:10 PM
real time application khodeir Programming 10 12-02-2009 09:38 AM
How do I manage CPU affinity FBO multiple instances of an application in RHEL v5.x? Kevin McLeod Linux - Newbie 2 02-05-2009 05:40 PM
CPU binding - How to modify the CPU affinity mask? Thaidog Linux - General 1 03-15-2008 05:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration