From: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/9] Add read-write lock to QEMU
Date: Thu, 14 Oct 2010 17:53:20 +0530 [thread overview]
Message-ID: <20101014122320.2238.26201.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20101014122217.2238.94995.stgit@localhost6.localdomain6>
From: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
---
qemu-thread.c | 40 ++++++++++++++++++++++++++++++++++++++++
qemu-thread.h | 10 ++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/qemu-thread.c b/qemu-thread.c
index fbc78fe..42774ff 100644
--- a/qemu-thread.c
+++ b/qemu-thread.c
@@ -90,6 +90,46 @@ void qemu_mutex_unlock(QemuMutex *mutex)
error_exit(err, __func__);
}
+void qemu_rwmutex_init(QemuRWMutex *mutex)
+{
+ int err;
+
+ err = pthread_rwlock_init(&mutex->lock, NULL);
+ if (err) {
+ error_exit(err, __func__);
+ }
+}
+
+void qemu_rwmutex_rdlock(QemuRWMutex *mutex)
+{
+ int err;
+
+ err = pthread_rwlock_rdlock(&mutex->lock);
+ if (err) {
+ error_exit(err, __func__);
+ }
+}
+
+void qemu_rwmutex_wrlock(QemuRWMutex *mutex)
+{
+ int err;
+
+ err = pthread_rwlock_wrlock(&mutex->lock);
+ if (err) {
+ error_exit(err, __func__);
+ }
+}
+
+void qemu_rwmutex_unlock(QemuRWMutex *mutex)
+{
+ int err;
+
+ err = pthread_rwlock_unlock(&mutex->lock);
+ if (err) {
+ error_exit(err, __func__);
+ }
+}
+
void qemu_cond_init(QemuCond *cond)
{
int err;
diff --git a/qemu-thread.h b/qemu-thread.h
index 19bb30c..1b0267e 100644
--- a/qemu-thread.h
+++ b/qemu-thread.h
@@ -7,6 +7,10 @@ struct QemuMutex {
pthread_mutex_t lock;
};
+struct QemuRWMutex {
+ pthread_rwlock_t lock;
+};
+
struct QemuCond {
pthread_cond_t cond;
};
@@ -16,6 +20,7 @@ struct QemuThread {
};
typedef struct QemuMutex QemuMutex;
+typedef struct QemuRWMutex QemuRWMutex;
typedef struct QemuCond QemuCond;
typedef struct QemuThread QemuThread;
@@ -26,6 +31,11 @@ int qemu_mutex_trylock(QemuMutex *mutex);
int qemu_mutex_timedlock(QemuMutex *mutex, uint64_t msecs);
void qemu_mutex_unlock(QemuMutex *mutex);
+void qemu_rwmutex_init(QemuRWMutex *mutex);
+void qemu_rwmutex_rdlock(QemuRWMutex *mutex);
+void qemu_rwmutex_wrlock(QemuRWMutex *mutex);
+void qemu_rwmutex_unlock(QemuRWMutex *mutex);
+
void qemu_cond_init(QemuCond *cond);
void qemu_cond_destroy(QemuCond *cond);
void qemu_cond_signal(QemuCond *cond);
next prev parent reply other threads:[~2010-10-14 12:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-14 12:23 [Qemu-devel] [RFC PATCH 0/9] Second threading model Arun R Bharadwaj
2010-10-14 12:23 ` Arun R Bharadwaj [this message]
2010-10-14 12:23 ` [Qemu-devel] [PATCH 2/9] Introduce lock fid_list_lock to protect the fid list Arun R Bharadwaj
2010-10-14 12:24 ` [Qemu-devel] [PATCH 3/9] Global rename lock Arun R Bharadwaj
2010-10-14 12:24 ` [Qemu-devel] [PATCH 4/9] Convert stat into 2nd threading model Arun R Bharadwaj
2010-10-14 12:24 ` [Qemu-devel] [PATCH 5/9] Convert wstat " Arun R Bharadwaj
2010-10-14 12:24 ` [Qemu-devel] [PATCH 6/9] Convert open " Arun R Bharadwaj
2010-10-14 12:25 ` [Qemu-devel] [PATCH 7/9] Convert walk " Arun R Bharadwaj
2010-10-14 12:25 ` [Qemu-devel] [PATCH 8/9] Convert read " Arun R Bharadwaj
2010-10-14 12:25 ` [Qemu-devel] [PATCH 9/9] Convert write " Arun R Bharadwaj
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101014122320.2238.26201.stgit@localhost6.localdomain6 \
--to=arun@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).