<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p></p>
<div>> </div>
<div>> Mere moments ago, quoth I:</div>
<div>> > On 28 April 2017 11:59, quoth Graeme Foot:</div>
<div>> > > 2) Your 0054 patch successfully moved the slave sdo request processing</div>
<div>> > > from the master fsm's idle state to be called every cycle of the master </div>
<div>> > > thread.</div>
<div>> > > However, I have my Linux environment set to run at 100Hz, so this</div>
<div>> > > thread would only fire once every 10ms. Each SDO read/write request</div>
<div>> > > would take approx. 30ms to complete. I didn't want to change Linux to</div>
<div>> > > run at 1000Hz so I</div>
<div>> > > created patch "etherlabmaster-0010-</div>
<div>> > > allow_app_to_process_sdo_requests_from_realtime.patch".</div>
<div>> > </div>
<div>> > Maybe I'm missing something about how the RTAI version works, but all I</div>
<div>> did</div>
<div>> > was to move the logic from inside fsm_master to inside fsm_slave; AFAIK</div>
<div>> > both of these execute on the same thread (either the master IDLE or master</div>
<div>> > OPERATION thread). This is independent of the application realtime loop</div>
<div>> > either way, so this should not have changed how frequently they run; it</div>
<div>> just</div>
<div>> > allows multiple slave requests to run in parallel rather than forcing them</div>
<div>> to</div>
<div>> > execute sequentially, so it should be a net performance gain.</div>
<div>> > </div>
<div>> > Though it does seem reasonable in your use case to want to run the slave</div>
<div>> > FSMs more often. I don't see how you could do that safely, though -- you</div>
<div>> > can't run ec_master_exec_slave_fsms outside of the master_sem lock, and</div>
<div>> > your RTAI task might interrupt Linux while it's still holding that lock,</div>
<div>> which will</div>
<div>> > deadlock your RTAI task.</div>
<div>> </div>
<div>> Are you configuring with --enable-hrtimer? After having a quick look at the</div>
<div>> code, I can see a potential performance degradation from the patch if you</div>
<div>> aren't using it (or did enable it but didn't call</div>
<div>> ec_master_set_send_interval with an appropriate value after activating the</div>
<div>> master). Perhaps you could try enabling that instead of using your patch</div>
<div>> and see if it helps?</div>
<div>> </div>
<p></p>
<div><font>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;">Hi,</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;">I don't use <span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">ec_master_set_send_interval()
or <span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">--enable-hrtimer since my masters operational thread has always run
at 10ms (100Hz) anyway. (I probably should so will look at adding that in at some stage.) My Linux kernel is configured to run at 100Hz and the master thread is not realtime so is scheduled by the Linux scheduler<span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"> (RTAI)</span>.
Because Linux is set to 100Hz, it only runs the masters operation thread once every 10ms.</span></span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">Prior
to your SDO patch, <span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span>ec_fsm_master_action_process_sdo</span>() was
being called by the masters fsm, but from its idle state. So it would only be called after all other processing and housekeeping was complete and was only being fired approx once every 800ms on my setup with 50 odd slaves. After the patch <span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">ec_master_exec_slave_fsms()
is now called every time the masters operational thread fires. All good except that on my system that is still only once every 10ms.</span></span></span></span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></span></span></span></div>
<div class="PlainText">So my new patch allows ec_master_exec_slave_fsms() to be called from my realtime context. As you pointed out the master_sem lock would cause a deadlock, so I don't use it. Because I don't use the lock I have instead added some flags
to track whether it is currently safe to make the <span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">ec_master_exec_slave_fsms()
call. It's generally just the rescan thats a problem.</span></div>
<div class="PlainText"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></div>
<div class="PlainText"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">I don't know if the patch will be useful for anyone
else, but is useful if Linux is configured for 100Hz. It may also be useful on short cycle time systems, e.g. 100 - 250us cycle times, where you want to process the SDO's faster. Even if Linux is set to 1000Hz is will only schedule the master operational
thread at 1ms. The master thread may also be delayed if the Linux side gets some heavy CPU usage.</span></div>
<div class="PlainText"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></div>
<div class="PlainText"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">Thanks
for thinking about it. I like getting feedback for my patches as its easy to overlook potential bugs or alternate solutions which can be better.</span></span></span></span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></span></span></span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></span></span></span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">Graeme.</span></span></span></span></div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><br>
</div>
<div class="PlainText" style="color: rgb(0, 0, 0); font-size: 10pt;"><br>
</div>
</font></div>
</div>
</body>
</html>