summaryrefslogtreecommitdiff
path: root/tests/mutex2.c
blob: d0885fcb2d9c2e1634839dd30d43766678a7c612 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* 
 * mutex1.c
 *
 * Declare a static mutex object, lock it, and then unlock it again.
 */

#include <pthread.h>
#include "test.h"
 
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;

main()
{
  int result;

  result = pthread_mutex_trylock(&mutex1);
  printf("pthread_mutex_trylock returned %s\n", error_string[result]);

  if (result == 0)
  {
    pthread_mutex_unlock(&mutex1);
  }

  return 0;
}