examples/ostest:  Add new error print and modify comments in cancel test.
@@ -90,7 +90,9 @@ static FAR void *thread_waiter(FAR void *parameter)
}
}
- /* Then wait -- we will never awaken from this. */
+ /* Then wait -- we will never awaken from this normaly. We will wake
+ * either by signal or cancellation.
+ */
status = pthread_cond_wait(&cond, &mutex);
if (status != 0)
@@ -98,6 +100,8 @@ static FAR void *thread_waiter(FAR void *parameter)
printf("thread_waiter: ERROR pthread_cond_wait failed, status=%d\n", status);
}
+ if (!parameter)
+ {
/* Release the mutex */
printf("thread_waiter: Releasing mutex\n");
@@ -115,6 +119,11 @@ static FAR void *thread_waiter(FAR void *parameter)
{
printf("thread_waiter: ERROR pthread_setcancelstate failed, status=%d\n", status);
}
+ }
+ else
+ {
+ printf("thread_waiter: ERROR pthread_cond_wait returned after being cancelled!\n");
+ }
printf("thread_waiter: Exit with status 0x12345678\n");
pthread_exit((pthread_addr_t)0x12345678);
@@ -248,7 +257,9 @@ static void restart_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter, in
printf("restart_thread: ERROR pthread_cond_destroy failed, status=%d\n", status);
}
- /* Destroy the mutex */
+ /* Destroy the mutex. Note that this relies on non-portable NuttX assumption,
+ * that it is possible to destroy a locked mutex owned by a cancelled thread.
+ */
printf("restart_thread: Destroying mutex\n");
status = pthread_mutex_destroy(&mutex);
@@ -312,7 +323,7 @@ void cancel_test(void)
}
}
- /* Test 2: Syncrhonous Cancel ****************************************/
+ /* Test 2: Asynchronous Cancel ***************************************/
printf("cancel_test: Test 2: Asynchronous Cancellation\n");
