<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>
<style type="text/css">.style1 {font-family: "Times New Roman";}</style></head><body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><span style="font-size: 12pt;">Thanks Joel!</span></p>
<p><span style="font-size: 12pt;">I said it was crashing, it's actually currently hanging, but it changes.  The common thread is it always seems to be in semaphore access functions w/at least one task in printf(). I don't think it's floating point, it looks
 like </span><span style="font-size: 12pt;">RTEMS_FLOATING_POINT is passed to rtems_task_create(), but I'll have to do some testing to be sure.</span><br>
</p>
<p><span style="font-size: 12pt;">The current backtrace I get when I </span><span style="font-size: 12pt;">^c after
</span><span style="font-size: 12pt;">it hangs is below.</span><br>
</p>
<p><span style="font-size: 12pt;">Dave</span><br>
</p>
<p><br>
</p>
<p></p>
<div><span style="font-family:"Courier New",monospace; font-size:8pt"> CPU 0: Interrupted!</span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">0x6005bad4: 80a08003 cmp %g2, %g3 <_Mutex_Acquire+52></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">CPU 1: Interrupted!</span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">0x6005ff98: 80a04002 cmp %g1, %g2 <_SMP_lock_Acquire+40></span><br>
<br>
<span style="font-family:"Courier New",monospace; font-size:8pt">grmon3> bt cpu0</span><br>
<br>
<span style="font-family:"Courier New",monospace; font-size:8pt">%pc %sp </span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#0 0x6005bad4 0x6047af58 <_Mutex_Acquire+0x34></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#1 0x60047558 0x6047b068 <rtems_termios_imfs_write+0xc></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#2 0x600495a4 0x6047b0e8 <write+0x84></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#3 0x600d558c 0x6047b148 <__sflush_r+0x1bc></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#4 0x600d56f0 0x6047b1a8 <_fflush_r+0x9c></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#5 0x600f086c 0x6047b208 <__sbprintf+0xb4></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#6 0x600db280 0x6047b6e8 <printf+0x2c></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#7 0x60030f30 0x6047b750 <SCH_ProcessNextEntry+0x1e8></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#8 0x60030fd0 0x6047b7f0 <SCH_ProcessNextSlot+0x94></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#9 0x6003111c 0x6047b850 <SCH_ProcessScheduleTable+0xb4></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#10 0x600314b4 0x6047b8b0 <SCH_AppMain+0x23c></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#11 0x60023d28 0x6047b928 <OS_TaskEntryPoint+0xb0></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#12 0x60056d28 0x6047b990 <_Thread_Entry_adaptor_numeric+0x8></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#13 0x60055878 0x6047b9f0 <_Thread_Handler+0xf4></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#14 0x60055784 0x6047ba58 <_Thread_Handler+0></span><br>
<br>
<span style="font-family:"Courier New",monospace; font-size:8pt">grmon3> bt cpu1</span><br>
<br>
<span style="font-family:"Courier New",monospace; font-size:8pt">%pc %sp </span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#0 0x6005ff98 0x60466ba8 <_SMP_lock_Acquire+0x28></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#1 0x60058164 0x60466ba8 <_Thread_queue_Surrender+0x54></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#2 0x6005bd4c 0x60466c10 <_Mutex_Release+0x7c></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#3 0x600475fc 0x60466d20 <rtems_termios_imfs_write+0xb0></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#4 0x600495a4 0x60466da0 <write+0x84></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#5 0x600d558c 0x60466e00 <__sflush_r+0x1bc></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#6 0x600d56f0 0x60466e60 <_fflush_r+0x9c></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#7 0x600f086c 0x60466ec0 <__sbprintf+0xb4></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#8 0x600db280 0x604673a0 <printf+0x2c></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#9 0x60029074 0x60467408 <SENSORS_dumpBytes+0xe8></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#10 0x60029324 0x604674c0 <SENSORS_ProcessSensorPacketSTUP+0xc4></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#11 0x60029764 0x60467528 <SENSORS_ProcessSPWRxPackets+0x210></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#12 0x600287bc 0x604675a0 <SENSORS_AppMain+0x6c></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#13 0x60023d28 0x60467608 <OS_TaskEntryPoint+0xb0></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#14 0x60056d28 0x60467670 <_Thread_Entry_adaptor_numeric+0x8></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#15 0x60055878 0x604676d0 <_Thread_Handler+0xf4></span><br>
<span style="font-family:"Courier New",monospace; font-size:8pt">#16 0x60055784 0x60467738 <_Thread_Handler+0></span></div>
<br>
<p></p>
<p><br>
</p>
<div style="color:rgb(0,0,0)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Joel Sherrill <joel@rtems.org><br>
<b>Sent:</b> Friday, April 30, 2021 4:21 PM<br>
<b>To:</b> Dave DeGroote<br>
<b>Cc:</b> users@rtems.org<br>
<b>Subject:</b> Re: Can printf() be made SMP safe?</font>
<div> </div>
</div>
<div>
<p></p>
<div style=""><span style="">CAUTION:</span> This email originated from outside of the organization.</div>
<br>
<p></p>
<div>
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Fri, Apr 30, 2021 at 2:07 PM Dave DeGroote <<a href="mailto:Dave.DeGroote@astrobotic.com">Dave.DeGroote@astrobotic.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="gmail-m_3300640327971901434divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><span style="font-size:12pt">Hello,</span></p>
<p><span style="font-size:12pt">I'm trying to get RTEMS running using SMP on a Leon3/gr712rc (2 cores). I have it partially running, but it crashes intermittently on printf's.  Can anyone tell me if there's a way to make printf() SMP safe?  printf appears to
 use termios which uses rtems_mutex_init() and rtems_binary_semaphore_init() which I don't think are SMP safe (but I'm also new to this so I'm not sure).</span></p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Those are SMP safe. I suspect you are using the Classic API (e.g. rtems_task_) and by default they do not have floating point enabled. You probably just need to enable the floating point attribute on the task create calls (or for the init task).</div>
<div><br>
</div>
<div><a href="https://docs.rtems.org/branches/master/c-user/task/directives.html#rtems-task-create">https://docs.rtems.org/branches/master/c-user/task/directives.html#rtems-task-create</a></div>
<div><br>
</div>
<div>See configuring a system chapter for the init task setting.</div>
<div><br>
</div>
<div>If you provide the exception, we would know for sure.</div>
<div><br>
</div>
<div>--joel </div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>


<br><br><p style="font-family: Verdana; font-size:10pt; color:#666666;"><b>Disclaimer</b></p><p style="font-family: Verdana; font-size:8pt; color:#666666;">The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.<br></p></body></html>