pthread conditions and process termination

后端 未结 3 1276
长情又很酷
长情又很酷 2021-01-12 14:55

I have a process-shared pthread condition (with associated mutex). What would happen if a process waiting on this condition (using pthread_cond_wait() or pthread_cond_timed

3条回答
  •  -上瘾入骨i
    2021-01-12 15:49

    One more option might be the explicitly call pthread_ond_broadcast() before calling pthread_cond_destroy().

    Like this:

    r = pthread_cond_broadcast(&c->c);
    puts("Before pthread_cond_destroy");
    r = pthread_cond_destroy(&c->c);
    printf("After pthread_cond_destroy, r=%d\n", r);
    r = pthread_mutex_destroy(&c->m);
    printf("After pthread_mutex_destroy, r=%d\n", r);
    

提交回复
热议问题