Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tools/regression/pthread/unwind/cond_wait_cancel.cpp
39553 views
1
/* Test stack unwinding for pthread_cond_wait function */
2
3
#include <pthread.h>
4
#include <stdio.h>
5
#include <semaphore.h>
6
#include <unistd.h>
7
8
#include "Test.cpp"
9
10
static pthread_mutex_t mtx;
11
static pthread_cond_t cv;
12
13
static void *
14
thr(void *arg __unused)
15
{
16
Test t;
17
18
pthread_mutex_lock(&mtx);
19
pthread_cond_wait(&cv, &mtx);
20
pthread_mutex_unlock(&mtx);
21
printf("Bug, thread shouldn't be here.\n");
22
return (0);
23
}
24
25
int
26
main()
27
{
28
pthread_t td;
29
30
pthread_mutex_init(&mtx, NULL);
31
pthread_cond_init(&cv, NULL);
32
pthread_create(&td, NULL, thr, NULL);
33
sleep(1);
34
pthread_cancel(td);
35
pthread_join(td, NULL);
36
check_destruct();
37
return (0);
38
}
39
40