[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V4 1/3] qemu: Add qemu-barrier support to qemu-threa
From: |
Gautham R Shenoy |
Subject: |
[Qemu-devel] [PATCH V4 1/3] qemu: Add qemu-barrier support to qemu-thread framework. |
Date: |
Wed, 16 Jun 2010 17:26:51 +0530 |
User-agent: |
StGit/0.15-51-gc750 |
Signed-off-by: Gautham R Shenoy <address@hidden>
---
qemu-thread.c | 23 +++++++++++++++++++++++
qemu-thread.h | 9 +++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/qemu-thread.c b/qemu-thread.c
index 3923db7..7c445b6 100644
--- a/qemu-thread.c
+++ b/qemu-thread.c
@@ -161,3 +161,26 @@ int qemu_thread_equal(QemuThread *thread1, QemuThread
*thread2)
return pthread_equal(thread1->thread, thread2->thread);
}
+void qemu_barrier_init(QemuBarrier *barr1, int nr_threads)
+{
+ int err;
+
+ err = pthread_barrier_init(&barr1->barr, NULL, nr_threads);
+
+ if (err) {
+ error_exit(err, __func__);
+ }
+}
+
+int qemu_barrier_wait(QemuBarrier *barr1)
+{
+ int ret;
+
+ ret = pthread_barrier_wait(&barr1->barr);
+
+ if (ret != 0 && ret != PTHREAD_BARRIER_SERIAL_THREAD) {
+ error_exit(ret, __func__);
+ }
+
+ return ret;
+}
diff --git a/qemu-thread.h b/qemu-thread.h
index 5ef4a3a..b3d36e0 100644
--- a/qemu-thread.h
+++ b/qemu-thread.h
@@ -15,9 +15,14 @@ struct QemuThread {
pthread_t thread;
};
+struct QemuBarrier {
+ pthread_barrier_t barr;
+};
+
typedef struct QemuMutex QemuMutex;
typedef struct QemuCond QemuCond;
typedef struct QemuThread QemuThread;
+typedef struct QemuBarrier QemuBarrier;
void qemu_mutex_init(QemuMutex *mutex);
void qemu_mutex_lock(QemuMutex *mutex);
@@ -31,10 +36,14 @@ void qemu_cond_broadcast(QemuCond *cond);
void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
int qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex, uint64_t msecs);
+void qemu_barrier_init(QemuBarrier *barr, int nr_threads);
+
void qemu_thread_create(QemuThread *thread,
void *(*start_routine)(void*),
void *arg);
void qemu_thread_signal(QemuThread *thread, int sig);
void qemu_thread_self(QemuThread *thread);
int qemu_thread_equal(QemuThread *thread1, QemuThread *thread2);
+
+int qemu_barrier_wait(QemuBarrier *barr);
#endif
- [Qemu-devel] [PATCH V4 0/3] qemu: Threadlets: A generic task offloading framework, Gautham R Shenoy, 2010/06/16
- [Qemu-devel] [PATCH V4 1/3] qemu: Add qemu-barrier support to qemu-thread framework.,
Gautham R Shenoy <=
- [Qemu-devel] [PATCH V4 2/3] qemu: Generic task offloading framework: threadlets, Gautham R Shenoy, 2010/06/16
- [Qemu-devel] Re: [PATCH V4 2/3] qemu: Generic task offloading framework: threadlets, Paolo Bonzini, 2010/06/16
- Re: [Qemu-devel] Re: [PATCH V4 2/3] qemu: Generic task offloading framework: threadlets, Jamie Lokier, 2010/06/16
- Re: [Qemu-devel] Re: [PATCH V4 2/3] qemu: Generic task offloading framework: threadlets, Anthony Liguori, 2010/06/16
- Re: [Qemu-devel] Re: [PATCH V4 2/3] qemu: Generic task offloading framework: threadlets, Paolo Bonzini, 2010/06/16
- Re: [Qemu-devel] Re: [PATCH V4 2/3] qemu: Generic task offloading framework: threadlets, Anthony Liguori, 2010/06/16
- Re: [Qemu-devel] Re: [PATCH V4 2/3] qemu: Generic task offloading framework: threadlets, Paolo Bonzini, 2010/06/16
- Re: [Qemu-devel] Re: [PATCH V4 2/3] qemu: Generic task offloading framework: threadlets, Anthony Liguori, 2010/06/16