summaryrefslogtreecommitdiff
path: root/util/qemu-thread-posix.c
diff options
context:
space:
mode:
authorSeokYeon Hwang <syeon.hwang@samsung.com>2016-12-20 10:13:15 +0900
committerSeokYeon Hwang <syeon.hwang@samsung.com>2016-12-20 10:13:15 +0900
commitdc36664b156b6aa2b55f2bca5fd0c643b6417ddb (patch)
treebb319daf3cd759c2d91dd541bb2ee24d8ca4ee1a /util/qemu-thread-posix.c
parent100d9fdc18f28d813f9d22025d783a7cdcc4bb4b (diff)
parent6a928d25b6d8bc3729c3d28326c6db13b9481059 (diff)
downloadqemu-dc36664b156b6aa2b55f2bca5fd0c643b6417ddb.tar.gz
qemu-dc36664b156b6aa2b55f2bca5fd0c643b6417ddb.tar.bz2
qemu-dc36664b156b6aa2b55f2bca5fd0c643b6417ddb.zip
Merge tag 'v2.8.0-rc4' into develop
v2.8.0-rc4 release Change-Id: I0158b5078d1af545dc32a51f10d2f8f0b96543a6 Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
Diffstat (limited to 'util/qemu-thread-posix.c')
-rw-r--r--util/qemu-thread-posix.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 0a1b87ccb9..4c0990250e 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -80,6 +80,20 @@ void qemu_mutex_unlock(QemuMutex *mutex)
error_exit(err, __func__);
}
+void qemu_rec_mutex_init(QemuRecMutex *mutex)
+{
+ int err;
+ pthread_mutexattr_t attr;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ err = pthread_mutex_init(&mutex->lock, &attr);
+ pthread_mutexattr_destroy(&attr);
+ if (err) {
+ error_exit(err, __func__);
+ }
+}
+
void qemu_cond_init(QemuCond *cond)
{
int err;
@@ -360,7 +374,11 @@ void qemu_event_destroy(QemuEvent *ev)
void qemu_event_set(QemuEvent *ev)
{
- if (atomic_mb_read(&ev->value) != EV_SET) {
+ /* qemu_event_set has release semantics, but because it *loads*
+ * ev->value we need a full memory barrier here.
+ */
+ smp_mb();
+ if (atomic_read(&ev->value) != EV_SET) {
if (atomic_xchg(&ev->value, EV_SET) == EV_BUSY) {
/* There were waiters, wake them up. */
futex_wake(ev, INT_MAX);
@@ -370,7 +388,11 @@ void qemu_event_set(QemuEvent *ev)
void qemu_event_reset(QemuEvent *ev)
{
- if (atomic_mb_read(&ev->value) == EV_SET) {
+ unsigned value;
+
+ value = atomic_read(&ev->value);
+ smp_mb_acquire();
+ if (value == EV_SET) {
/*
* If there was a concurrent reset (or even reset+wait),
* do nothing. Otherwise change EV_SET->EV_FREE.
@@ -383,7 +405,8 @@ void qemu_event_wait(QemuEvent *ev)
{
unsigned value;
- value = atomic_mb_read(&ev->value);
+ value = atomic_read(&ev->value);
+ smp_mb_acquire();
if (value != EV_SET) {
if (value == EV_FREE) {
/*