diff --git a/examples/ostest/cancel.c b/examples/ostest/cancel.c index 73b214955..0aad378d5 100644 --- a/examples/ostest/cancel.c +++ b/examples/ostest/cancel.c @@ -33,19 +33,40 @@ * ****************************************************************************/ +#include + #include #include #include #include + #include "ostest.h" static pthread_mutex_t mutex; static pthread_cond_t cond; -static void *thread_waiter(void *parameter) +#ifdef CONFIG_PTHREAD_CLEANUP +static void thread_cleaner(FAR void *arg) +{ + printf("thread_cleaner #%u\n", (unsigned int)((uintptr_t)arg)); +} +#endif + +static FAR void *thread_waiter(FAR void *parameter) { int status; +#ifdef CONFIG_PTHREAD_CLEANUP + int i; + + /* Register some clean-up handlers */ + + for (i = 0; i < CONFIG_PTHREAD_CLEANUP_STACKSIZE ; i++) + { + pthread_cleanup_push(thread_cleaner, (FAR void *)((uintptr_t)(i+1))); + } +#endif + /* Take the mutex */ printf("thread_waiter: Taking mutex\n");