Statistics
| Branch: | Revision:

root / qemu-thread.h @ 313b1d69

History | View | Annotate | Download (1.2 kB)

1
#ifndef __QEMU_THREAD_H
2
#define __QEMU_THREAD_H 1
3
#include "semaphore.h"
4
#include "pthread.h"
5

    
6
struct QemuMutex {
7
    pthread_mutex_t lock;
8
};
9

    
10
struct QemuCond {
11
    pthread_cond_t cond;
12
};
13

    
14
struct QemuThread {
15
    pthread_t thread;
16
};
17

    
18
typedef struct QemuMutex QemuMutex;
19
typedef struct QemuCond QemuCond;
20
typedef struct QemuThread QemuThread;
21

    
22
void qemu_mutex_init(QemuMutex *mutex);
23
void qemu_mutex_destroy(QemuMutex *mutex);
24
void qemu_mutex_lock(QemuMutex *mutex);
25
int qemu_mutex_trylock(QemuMutex *mutex);
26
int qemu_mutex_timedlock(QemuMutex *mutex, uint64_t msecs);
27
void qemu_mutex_unlock(QemuMutex *mutex);
28

    
29
void qemu_cond_init(QemuCond *cond);
30
void qemu_cond_destroy(QemuCond *cond);
31
void qemu_cond_signal(QemuCond *cond);
32
void qemu_cond_broadcast(QemuCond *cond);
33
void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
34
int qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex, uint64_t msecs);
35

    
36
void qemu_thread_create(QemuThread *thread,
37
                       void *(*start_routine)(void*),
38
                       void *arg);
39
void qemu_thread_signal(QemuThread *thread, int sig);
40
void qemu_thread_self(QemuThread *thread);
41
int qemu_thread_equal(QemuThread *thread1, QemuThread *thread2);
42
void qemu_thread_exit(void *retval);
43

    
44
#endif