LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-04-2017, 09:04 PM   #1
barz_83_LQ
LQ Newbie
 
Registered: Apr 2017
Posts: 17

Rep: Reputation: Disabled
Linux real time scheduler priority attributes and timing analysis


Hello,

(You can skip to questions at the end.)

I have a real time program in C simply as below:

void func() /* This would be called as a normal pthread from main */
{
/* some code here */

attr.sched_runtime = 500000; // 0.5 ms
attr.sched_deadline = 500000; // 0.5 ms
attr.sched_period = 1000000; // 1ms

attr.size = sizeof (attr);

attr.sched_flags = 0;
attr.sched_nice = 0;
attr.sched_priority = 0;

ret = sched_setattr(0, &attr, flags);
if (ret != 0)
perror("Error ");

/* some more code here */

while(1)
{
/* realtime processing code here */

sched_yield();

/* time_elapsed() returns time diff (in ms) between previous and current invocation of time_elapsed() */
cycle_period_time_taken = time_elapsed();
/* cycle_period_time_taken is plotted across time to check jitter*/
time_elapsed();

/* Data produce to be consumed by other process */

/* while break condition code */
}

Now, the questions are:

1) Am not able to modify attr.sched_priority and am getting error Invalid argument, in case I modify it to other than 0. How can I set attr values to make the thread of the highest real time priority thread, I think I need to set to 99 but unable to do so.
2) is it apt method to do timing analysis as above using time_elapsed() in the code. (This is easier especially to plot, may be I can use tracefs but that would be difficult to plot. Inputs appreciated in better or other methods for doing timing analysis using tools like perf, tracefs, uprobes).

Thanks and regards,
Bhargav
 
Old 12-05-2017, 04:24 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 17,168

Rep: Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562Reputation: 2562
Are you using a RTOS version of linux or some near real time adaptation?


I could be wrong but as far as I know most open sourced linux gave up on real time because of any number of issues from drivers to scheduler. Someone may correct me on that.

There are a few RTOS linux out there as well as things like QNX.
 
Old 12-05-2017, 09:17 PM   #3
barz_83_LQ
LQ Newbie
 
Registered: Apr 2017
Posts: 17

Original Poster
Rep: Reputation: Disabled
@jefro,
Okay, I am using preempt_rt patch.

Thanks and regards,
Bhargav
 
Old 12-05-2017, 11:35 PM   #4
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 3,270

Rep: Reputation: 584Reputation: 584Reputation: 584Reputation: 584Reputation: 584Reputation: 584
sched_priority

This field specifies the static priority to be set when specifying sched_policy as SCHED_FIFO or SCHED_RR. The allowed range of priorities for these policies can be determined using sched_get_priority_min(2) and sched_get_priority_max(2). For other policies, this field must be specified as 0.
 
1 members found this post helpful.
  


Reply

Tags
attributes, realtime, scheduler, timing, tuning


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
Linux pthread priority real time scheduler (SCHED_RR) doesn't seem work properly Jia Hong Programming 4 04-30-2014 08:16 AM
Linux pthread priority real time scheduler (SCHED_RR) doesn't seem work properly Jia Hong Linux - Software 1 04-29-2014 02:26 AM
Linux pthread priority real time scheduler (SCHED_RR) doesn't seem work properly Jia Hong Linux - Kernel 1 04-29-2014 02:26 AM

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

All times are GMT -5. The time now is 09:19 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