summaryrefslogtreecommitdiff
path: root/linux-user/mmap.c
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2008-06-07 20:50:51 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2008-06-07 20:50:51 +0000
commitd597536303d762c4209cbab7e379819b8eb14536 (patch)
tree3330934421d15c1d5d1f95e18fe9bc36da7cc6cd /linux-user/mmap.c
parent0a878c4760718e1604e2cfe423252729716110ad (diff)
downloadqemu-d597536303d762c4209cbab7e379819b8eb14536.tar.gz
Multithreaded locking fixes.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4692 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user/mmap.c')
-rw-r--r--linux-user/mmap.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index c0821386d9..b4ca1074b3 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -46,6 +46,22 @@ void mmap_unlock(void)
pthread_mutex_unlock(&mmap_mutex);
}
}
+
+/* Grab lock to make sure things are in a consistent state after fork(). */
+void mmap_fork_start(void)
+{
+ if (mmap_lock_count)
+ abort();
+ pthread_mutex_lock(&mmap_mutex);
+}
+
+void mmap_fork_end(int child)
+{
+ if (child)
+ pthread_mutex_init(&mmap_mutex, NULL);
+ else
+ pthread_mutex_unlock(&mmap_mutex);
+}
#else
/* We aren't threadsafe to start with, so no need to worry about locking. */
void mmap_lock(void)