1 /* { dg-options "-fprofile-arcs -ftest-coverage -pthread -fprofile-update=atomic" } */
2 /* { dg-do run { target native } } */
3 /* { dg-require-effective-target profile_update_atomic } */
11 pthread_mutex_t cndMs[NR];
12 static void *ContentionNoDeadlock_thread(void *start)
14 for (uint32_t k = 0; k < 100000; ++k) /* count(500005) */
16 int starti = *(int*)start; /* count(500000) */
17 for (uint32_t i = starti; i < NR; ++i)
18 pthread_mutex_lock (&cndMs[i]);
19 for (int32_t i = NR - 1; i >= starti; --i)
20 pthread_mutex_unlock (&cndMs[i]);
25 int main(int argc, char **argv) {
26 for (unsigned i = 0; i < NR; i++)
27 cndMs[i] = PTHREAD_MUTEX_INITIALIZER;
32 for (int i = 0; i < NR; i++)
35 int r = pthread_create (&t[i], NULL, ContentionNoDeadlock_thread, &ids[i]);
36 assert (r == 0); /* count(5*) */
40 for (int i = 0; i < NR; i++)
42 int r = pthread_join (t[i], (void**)&ret);
43 assert (r == 0); /* count(5*) */
46 return 0; /* count(1) */
49 /* { dg-final { run-gcov gcov-threads-1.C } } */