<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Alexey Kodanev <<a href="mailto:aleksei.kodanev@bell-sw.com">aleksei.kodanev@bell-sw.com</a>> wrote:<br></div></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br>
> Maybe another workaround is to define a volatile flag 'thread_complete', <br>
> initialize it to '0' when thread_B starts and reset to '1' while exit, and just<br>
> do a value check in the while loop of thread_A should acquire thread_B status.<br>
> Is this way a bit better? <br>
<br>
OK, why not, so something like this:<br>
<br>
diff --git a/testcases/kernel/crypto/af_alg02.c b/testcases/kernel/crypto/af_alg02.c<br>
index 0f5793c16..1fe0f3bf0 100644<br>
--- a/testcases/kernel/crypto/af_alg02.c<br>
+++ b/testcases/kernel/crypto/af_alg02.c<br>
@@ -18,11 +18,13 @@<br>
#include "tst_test.h"<br>
#include "tst_af_alg.h"<br>
#include "tst_safe_pthread.h"<br>
+#include "tst_atomic.h"<br>
#include <pthread.h><br>
#include <errno.h><br>
<br>
#define SALSA20_IV_SIZE 8<br>
#define SALSA20_MIN_KEY_SIZE 16<br>
+static int completed;<br>
<br>
static void *verify_encrypt(void *arg)<br>
{<br>
@@ -48,6 +50,8 @@ static void *verify_encrypt(void *arg)<br>
tst_res(TPASS, "Successfully \"encrypted\" an empty message");<br>
else<br>
tst_res(TFAIL, "read() didn't return 0");<br>
+<br>
+ tst_atomic_store(1, &completed);<br>
return arg;<br>
}<br>
<br>
@@ -60,7 +64,7 @@ static void run(void)<br>
<br>
TST_CHECKPOINT_WAIT(0);<br>
<br>
- while (pthread_tryjoin_np(thr, NULL) == EBUSY) {<br>
+ while (!tst_atomic_load(&completed)) {<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">+1</div><div class="gmail_default" style="font-size:small">The atomic method is quite awesome!</div><div class="gmail_default" style="font-size:small"></div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>