LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 08:04 PM   #1
barz_83_LQ
Member
 
Registered: Apr 2017
Posts: 31

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, 03:24 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,981

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
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, 08:17 PM   #3
barz_83_LQ
Member
 
Registered: Apr 2017
Posts: 31

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

Thanks and regards,
Bhargav
 
Old 12-05-2017, 10:35 PM   #4
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
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



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

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

All times are GMT -5. The time now is 05:40 PM.

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
Open Source Consulting | Domain Registration