Home | History | Annotate | Download | only in pthread_mutex_init

Lines Matching defs:mutex

9  *   Upon successful initialization, the state of the mutex becomes
21 pthread_mutex_t mutex;
24 /* Initialize a mutex object */
25 if ((rc = pthread_mutex_init(&mutex, NULL)) != 0) {
26 fprintf(stderr, "Fail to initialize mutex, rc=%d\n", rc);
31 /* Acquire the mutex object using pthread_mutex_lock */
32 if ((rc = pthread_mutex_lock(&mutex)) != 0) {
33 fprintf(stderr, "Fail to lock the mutex, rc=%d\n", rc);
37 fprintf(stderr, "Main: hold the mutex for a while\n");
40 /* Release the mutex object using pthread_mutex_unlock */
41 if ((rc = pthread_mutex_unlock(&mutex)) != 0) {
42 fprintf(stderr, "Fail to unlock the mutex, rc=%d\n", rc);
46 /* Destory the mutex object */
47 if ((rc = pthread_mutex_destroy(&mutex)) != 0) {
48 fprintf(stderr, "Fail to destory the mutex, rc=%d\n", rc);