<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Nov 5, 2013, at 9:29 PM, ayoade gbadebo <<a href="mailto:gbaduz@gmail.com">gbaduz@gmail.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>I am trying to follow the tutorial on implementing a plugin,<br></div> but it complains about this function and RT_F_SLEEP <br><div>get_rt_flags(prev) == RT_F_SLEEP and set_rt_flags(tsk, RT_F_RUNNING);<br>
<br></div><div>What functions replaced them<br><br></div><div>Thanks<br></div></div>
_______________________________________________<br>litmus-dev mailing list<br><a href="mailto:litmus-dev@lists.litmus-rt.org">litmus-dev@lists.litmus-rt.org</a><br>https://lists.litmus-rt.org/listinfo/litmus-dev</blockquote></div><div><br></div><div><br></div><div>You might want to look at the schedule() code for some of the other plugins for hints. I think this code from sched_psn_edf.c::psnedf_schedule(…) is relevant:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"> exists = pedf->scheduled != <span style="color: #c33720">NULL</span>;</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"> blocks = exists && !is_running(pedf->scheduled);</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"> out_of_time = exists &&</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"> budget_enforced(pedf->scheduled) &&</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"> budget_exhausted(pedf->scheduled);</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"> np = exists && is_np(pedf->scheduled);</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"> sleep = exists && is_completed(pedf->scheduled);</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"> preempt = edf_preemption_needed(edf, pref);</div></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><br></div><div>There are several is_*() macros (see include/litmus/litmus.h) and inline functions that replace reading these flags. I believe the flags were replaced by “unsigned int:1” boolean bitfields in struct rt_param (this may not be as efficient as OR’ing and AND’ing flags, but it’s a lot easier to work with). For example, here’s the code for litmus.h::is_completed():</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><span style="color: #34bd26">static</span> <span style="color: #34bd26">inline</span> <span style="color: #34bd26">int</span> <span style="background-color: #e6e600">is_completed</span>(<span style="color: #34bd26">struct</span> task_struct* t)</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';">{</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"> <span style="color: #ce7924">return</span> t && tsk_rt(t)->completed; // here’s the declaration for completed: "<span style="color: rgb(52, 189, 38);">unsigned</span> <span style="color: rgb(52, 189, 38);">int </span><span style="background-color: rgb(230, 230, 0);">completed</span>:<span style="color: rgb(195, 55, 32);">1</span>;"</div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';">}</div></div><div style="margin: 0px; font-size: 11px; font-family: 'Source Code Pro';"><br></div><div style="margin: 0px;"><div style="margin: 0px;">Let’s look at an old Litmus implementation for the same part of sched_psn_edf.c::psnedf_schedule(…):</div><div style="font-family: 'Source Code Pro'; font-size: 11px; margin: 0px;"><span style="font-family: Helvetica; font-size: 12px;"><br></span></div><div style="font-family: Helvetica; font-size: 12px; margin: 0px;"><span style="font-family: 'Source Code Pro'; font-size: 11px;"> </span> <font face="Source Code Pro"><span style="font-size: 11px;">exists = pedf->scheduled != NULL;<br></span></font><div><span style="font-family: 'Source Code Pro'; font-size: 11px;"> </span> <font face="Source Code Pro"><span style="font-size: 11px;">blocks </span></font><span style="font-size: 11px; font-family: 'Source Code Pro';">=</span><span style="font-size: 11px; font-family: 'Source Code Pro';"> exists </span><span style="font-size: 11px; font-family: 'Source Code Pro';">&& !</span><span style="font-size: 11px; font-family: 'Source Code Pro';">is_running</span><span style="font-size: 11px; font-family: 'Source Code Pro';">(</span><span style="font-size: 11px; font-family: 'Source Code Pro';">pedf</span><span style="font-size: 11px; font-family: 'Source Code Pro';">-></span><span style="font-size: 11px; font-family: 'Source Code Pro';">scheduled</span><span style="font-size: 11px; font-family: 'Source Code Pro';">);</span></div><div><span style="font-family: 'Source Code Pro'; font-size: 11px;"> </span> <font face="Source Code Pro"><span style="font-size: 11px;">out_of_time </span></font><span style="font-size: 11px; font-family: 'Source Code Pro';">=</span><span style="font-size: 11px; font-family: 'Source Code Pro';"> exists </span><span style="font-size: 11px; font-family: 'Source Code Pro';">&&</span></div><div><span style="font-family: 'Source Code Pro'; font-size: 11px;"> </span> <span style="font-size: 11px; font-family: 'Source Code Pro';">budget_enforced</span><span style="font-size: 11px; font-family: 'Source Code Pro';">(</span><span style="font-size: 11px; font-family: 'Source Code Pro';">pedf</span><span style="font-size: 11px; font-family: 'Source Code Pro';">-></span><span style="font-size: 11px; font-family: 'Source Code Pro';">scheduled</span><span style="font-size: 11px; font-family: 'Source Code Pro';">) &&</span></div><div><span style="font-family: 'Source Code Pro'; font-size: 11px;"> </span> <span style="font-size: 11px; font-family: 'Source Code Pro';">budget_exhausted</span><span style="font-size: 11px; font-family: 'Source Code Pro';">(</span><span style="font-size: 11px; font-family: 'Source Code Pro';">pedf</span><span style="font-size: 11px; font-family: 'Source Code Pro';">-></span><span style="font-size: 11px; font-family: 'Source Code Pro';">scheduled</span><span style="font-size: 11px; font-family: 'Source Code Pro';">);</span></div><div><span style="font-family: 'Source Code Pro'; font-size: 11px;"> </span> <font face="Source Code Pro"><span style="font-size: 11px;">np<span class="Apple-tab-span" style="white-space: pre;"> </span></span></font><span style="font-size: 11px; font-family: 'Source Code Pro';">=</span><span style="font-size: 11px; font-family: 'Source Code Pro';"> exists </span><span style="font-size: 11px; font-family: 'Source Code Pro';">&&</span><span style="font-size: 11px; font-family: 'Source Code Pro';"> </span><span style="font-size: 11px; font-family: 'Source Code Pro';">is_np</span><span style="font-size: 11px; font-family: 'Source Code Pro';">(</span><span style="font-size: 11px; font-family: 'Source Code Pro';">pedf</span><span style="font-size: 11px; font-family: 'Source Code Pro';">-></span><span style="font-size: 11px; font-family: 'Source Code Pro';">scheduled</span><span style="font-size: 11px; font-family: 'Source Code Pro';">);</span></div><div><span style="font-family: 'Source Code Pro'; font-size: 11px;"> </span> <font face="Source Code Pro"><span style="font-size: 11px;">sleep </span></font><span style="font-size: 11px; font-family: 'Source Code Pro';">=</span><span style="font-size: 11px; font-family: 'Source Code Pro';"> exists </span><span style="font-size: 11px; font-family: 'Source Code Pro';">&&</span><span style="font-size: 11px; font-family: 'Source Code Pro';"> </span><span style="font-size: 11px; font-family: 'Source Code Pro';">get_rt_flags</span><span style="font-size: 11px; font-family: 'Source Code Pro';">(</span><span style="font-size: 11px; font-family: 'Source Code Pro';">pedf</span><span style="font-size: 11px; font-family: 'Source Code Pro';">-></span><span style="font-size: 11px; font-family: 'Source Code Pro';">scheduled</span><span style="font-size: 11px; font-family: 'Source Code Pro';">) ==</span><span style="font-size: 11px; font-family: 'Source Code Pro';"> RT_F_SLEEP</span><span style="font-size: 11px; font-family: 'Source Code Pro';">;</span></div><div><span style="font-family: 'Source Code Pro'; font-size: 11px;"> </span> <font face="Source Code Pro"><span style="font-size: 11px;">preempt </span></font><span style="font-size: 11px; font-family: 'Source Code Pro';">=</span><span style="font-size: 11px; font-family: 'Source Code Pro';"> </span><span style="font-size: 11px; font-family: 'Source Code Pro';">edf_preemption_needed</span><span style="font-size: 11px; font-family: 'Source Code Pro';">(</span><span style="font-size: 11px; font-family: 'Source Code Pro';">edf</span><span style="font-size: 11px; font-family: 'Source Code Pro';">,</span><span style="font-size: 11px; font-family: 'Source Code Pro';"> prev);</span></div></div><div style="font-family: 'Source Code Pro'; font-size: 11px; margin: 0px;"><br></div><div style="margin: 0px;">See where the value for “sleep” is computed? I think it’s safe to assume “get_rt_flags(tsk) == RT_F_SLEEP” is equivalent to "is_completed(tsk)”. Furthermore, comparing the old Litmus code against the new, I believe “set_rt_flags(tsk, RT_F_SLEEP)” is equivalent to “tsk_rt(t)->completed = 1” and “set_rt_flags(tsk, RT_F_RUNNING)” is equivalent to “tsk_rt(t)->completed = 0”. Regarding the flag “<span style="white-space: pre-wrap;">RT_F_EXIT_SEM”, I think this functionality has been replaced by logic relating to task release policy (</span><span style="font-family: 'Source Code Pro'; font-size: 11px;">release_policy_t</span>)<span style="white-space: pre-wrap;"> in task wake-up routines.</span></div><div style="margin: 0px;"><span style="white-space: pre-wrap;"><br></span></div><div style="margin: 0px;"><span style="white-space: pre-wrap;">Here’s a patch for an older version of Litmus that you can search through for examples of RT_F_*: </span><a href="http://www.litmus-rt.org/releases/2012.2/litmus-rt-2012.2.patch">http://www.litmus-rt.org/releases/2012.2/litmus-rt-2012.2.patch</a></div><div style="font-family: Helvetica; font-size: 12px; margin: 0px;"><br></div><div style="font-family: Helvetica; font-size: 12px; margin: 0px;">I didn’t run into any situations where I couldn’t correlate an old segment of code with equivalent code in the newest version of Litmus, but please feel free to ask more questions if you run into trouble.</div><div style="font-family: Helvetica; font-size: 12px; margin: 0px;"><br></div><div style="font-family: Helvetica; font-size: 12px; margin: 0px;">-Glenn</div></div></body></html>