~ubuntu-branches/ubuntu/saucy/mutextrace/saucy-proposed

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef mutextrace_store_h_
#define mutextrace_store_h_ 1

#include <pthread.h>

enum state
{
    uninitialized = 0,
    unlocked = 1,
    locked = 2,
    destroyed = 3
};

struct mutex;

struct thread
{
    pthread_t thread;

    struct thread *left;
    struct thread *right;

    unsigned int num;

    struct mutex *owns;
};

struct mutex
{
    pthread_mutex_t *mutex;

    struct mutex *left;
    struct mutex *right;

    pthread_mutex_t lock;
    pthread_cond_t cond;

    unsigned int num;
    enum state state;
    int kind;

    /* Ownership tracking */
    struct thread *owner;
    struct mutex *owns_next;
};

struct thread *find_thread(pthread_t);
struct mutex *find_mutex(pthread_mutex_t *);

#endif