File: test_common_pthread.c

package info (click to toggle)
libomemo-c 0.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,092 kB
  • sloc: ansic: 25,957; makefile: 8
file content (27 lines) | stat: -rw-r--r-- 623 bytes parent folder | download
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
26
27
#include <pthread.h>

pthread_mutex_t global_mutex;
pthread_mutexattr_t global_mutex_attr;

void test_global_mutex_lock(void *user_data)
{
    pthread_mutex_lock(&global_mutex);
}

void test_global_mutex_unlock(void *user_data)
{
    pthread_mutex_unlock(&global_mutex);
}

void test_global_mutex_setup()
{
    pthread_mutexattr_init(&global_mutex_attr);
    pthread_mutexattr_settype(&global_mutex_attr, PTHREAD_MUTEX_RECURSIVE);
    pthread_mutex_init(&global_mutex, &global_mutex_attr);
}

void test_global_mutex_teardown()
{
    pthread_mutex_destroy(&global_mutex);
    pthread_mutexattr_destroy(&global_mutex_attr);
}