<div dir="ltr"><div style="font-size:small" class="gmail_default"><br></div><div class="gmail_extra">Jan Stancek <span dir="ltr"><<a target="_blank" href="mailto:jstancek@redhat.com">jstancek@redhat.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span class="gmail-">This test sets priorities, measures time, tries to synchronize<br>
threads with integers and sleeps for seconds. And there appears<br>
to be race somewhere that makes it rarely fail.<br>
<br>
The premise tested is that action triggered by pthread_cancel<br>
runs asynchronously. This rewrite takes simpler approach:<br>
<br>
Thread sleeps until it can observe variable set by parent<br>
_after_ pthread_cancel() or after it hits specified timeout.<br>
If timeout is hit, then presumably cleanup_func() didn't<br>
run in parallel with main thread and test fails.<br>
<br>
Signed-off-by: Jan Stancek <<a href="mailto:jstancek@redhat.com">jstancek@redhat.com</a>></span><br><div><div class="gmail-h5">
<div style="font-size:small;display:inline" class="gmail_default">[...]</div><br></div></div>
<span class="gmail-">
+static void cleanup_func(void *unused)<br></span></blockquote><div style="font-size:small" class="gmail_default"><br>To get rid of compile warning:</div><div><div class="gmail_default" style="font-size:small;display:inline"> static void cleanup_func(void *unused __attribute__((unused)))<br></div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span class="gmail-">
+{<br>
+ do {<br>
+ usleep(SLEEP_MS*1000);<br>
+ thread_sleep_time += SLEEP_MS;<br>
+ } while (after_cancel == 0 && thread_sleep_time < TIMEOUT_MS);<br>
+}<br>
+<br>
+static void *thread_func(void *unused)<br></span></blockquote><div> </div><div><div class="gmail_default" style="font-size:small;display:inline">Here as well.</div><br></div></div><br><div class="gmail_default" style="font-size:small">Others looks good to me.</div><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div>
</div></div>