<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }div.foxdiv20170922161819452658 { }body { font-size: 10.5pt; font-family: 微软雅黑; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span>I found out that there is a test in 4.12-master about pthread_getattr_np, so I compiled that one and ran it.</div><div><br></div><div>The result shows that this function works well, like this</div><div>*************************************************************************</div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">*** BEGIN OF TEST PSXGETATTRNP 1 ***<br>Init - pthread_getattr_np - attr NULL - EINVAL<br>Init - pthread_getattr_np - invalid id - ESRCH<br>Init - pthread_attr_init<br>Init - pthread_attr_setinheritsched - PTHREAD_EXPLICIT_SCHED<br>Init - pthread_attr_setschedpolicy to SCHED_RR<br>Init - pthread_attr_setschedparam to minimum priority + 2<br>Init - pthread_attr_getstack<br>Init - pthread_attr_setstack double the stacksize<br>Init - pthread_attr_getguardsize<br>Init - pthread_attr_setguardsize double the guardsizecreate<br>Init - Lower pri<br>Init - raise priority to max<br>Init - pthread_ority<br>Thread - pthread_getattr_np - Verify value<br>Thread - pthread_setschedparam: Setting highest priority SCHED_FIFO<br>Thread - Detach<br>Thread - pthread_getattr_np<br>Thread - Verify SCHED_FIFO policy<br>Thread - Verify max priority<br>Thread - Verify detached<br>*** END OF </span></div><div>*************************************************************************</div><div><br></div><div>But, this test just checks the return value, not the value of elements in pthread_attr_t structure. When I tried to print out these values, the same result as before appeared, all 0...</div>
<div><br></div><div>So, how can I modify the source code in rtems to let this function work? Thanks a lot.</div><div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>Best wishes,</div><div>xuelin.tian@qkmtech.com</div></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:xuelin.tian@qkmtech.com">xuelin.tian@qkmtech.com</a></div><div><b>Date:</b> 2017-09-20 14:45</div><div><b>To:</b> <a href="mailto:sebastian.huber@embedded-brains.de">Sebastian Huber</a>; <a href="mailto:users@rtems.org">users@rtems.org</a></div><div><b>Subject:</b> Re: Re: pthread_getattr_np does not work</div></div></div><div><div class="FoxDiv20170922161819452658">
<div><span></span><div>I need to get thread attributes through this function. </div><div><br></div><div>**********************************************************************</div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">#define __GNU_VISIBLE<br>#include <pthread.h></span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);"><br></span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">void<br>test_thread (guint8 **staddr, size_t *stsize)<br>{<br><span style="white-space: pre;">       </span>pthread_attr_t attr;<br><span style="white-space: pre;">        uint8_t *</span>*staddr = NULL;<br><span style="white-space: pre;">       size_t </span>*stsize = 0;</span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">        int res = 0;<br><br><span style="white-space: pre;"> res = </span>pthread_getattr_np (pthread_self(), &attr);<br><span style="white-space: pre;">  </span>pthread_attr_getstack (&attr, (void**)staddr, stsize);<br><span style="white-space: pre;">        </span>pthread_attr_destroy (&attr);<br>}</span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">************************************************************************</span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);"><br></span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">I check the return value is 0 which means pthread_getattr_np goes well. But all values in attr structure are either 0 or 1. And I can not get staddr and stsize value either.</span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);"><br></span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">So, I think there may be something wrong with this function.</span></div></div>
<div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>Best wishes,</div><div>xuelin.tian@qkmtech.com</div></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:sebastian.huber@embedded-brains.de">Sebastian Huber</a></div><div><b>Date:</b> 2017-09-20 13:00</div><div><b>To:</b> <a href="mailto:xuelin.tian@qkmtech.com">xuelin.tian@qkmtech.com</a>; <a href="mailto:users@rtems.org">users@rtems.org</a></div><div><b>Subject:</b> Re: pthread_getattr_np does not work</div></div></div><div><div>On 20/09/17 05:43, xuelin.tian@qkmtech.com wrote:</div>
<div> </div>
<div>> Dear all,</div>
<div>> I tried to use pthread_getattr_np function to extract attrributes of </div>
<div>> thread in rtems, but it does not work. Has anyone used this function </div>
<div>> before?</div>
<div> </div>
<div>What do you mean with doesn't work?</div>
<div> </div>
<div>-- </div>
<div>Sebastian Huber, embedded brains GmbH</div>
<div> </div>
<div>Address : Dornierstr. 4, D-82178 Puchheim, Germany</div>
<div>Phone   : +49 89 189 47 41-16</div>
<div>Fax     : +49 89 189 47 41-09</div>
<div>E-Mail  : sebastian.huber@embedded-brains.de</div>
<div>PGP     : Public key available on request.</div>
<div> </div>
<div>Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.</div>
</div></blockquote>
</div></div></blockquote>
</body></html>