[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v10 05/24] replay: introduce mutex to protect th
From: |
Pavel Dovgalyuk |
Subject: |
[Qemu-devel] [RFC PATCH v10 05/24] replay: introduce mutex to protect the replay log |
Date: |
Fri, 27 Feb 2015 16:10:16 +0300 |
User-agent: |
StGit/0.16 |
This mutex will protect read/write operations for replay log.
Using mutex is necessary because most of the events consist of
several fields stored in the log. The mutex will help to avoid races.
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Pavel Dovgalyuk <address@hidden>
---
replay/replay-internal.c | 27 +++++++++++++++++++++++++++
replay/replay-internal.h | 7 +++++++
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/replay/replay-internal.c b/replay/replay-internal.c
index c2bbf5f..f7c03bc 100755
--- a/replay/replay-internal.c
+++ b/replay/replay-internal.c
@@ -15,6 +15,13 @@
unsigned int replay_data_kind = -1;
static unsigned int replay_has_unread_data;
+/* Mutex to protect reading and writing events to the log.
+ replay_data_kind and replay_has_unread_data are also protected
+ by this mutex.
+ It also protects replay events queue which stores events to be
+ written or read to the log. */
+static QemuMutex lock;
+
/* File for replay writing */
FILE *replay_file;
@@ -147,3 +154,23 @@ void replay_finish_event(void)
replay_has_unread_data = 0;
replay_fetch_data_kind();
}
+
+void replay_mutex_init(void)
+{
+ qemu_mutex_init(&lock);
+}
+
+void replay_mutex_destroy(void)
+{
+ qemu_mutex_destroy(&lock);
+}
+
+void replay_mutex_lock(void)
+{
+ qemu_mutex_lock(&lock);
+}
+
+void replay_mutex_unlock(void)
+{
+ qemu_mutex_unlock(&lock);
+}
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index 17600de..8a0de0d 100755
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -33,6 +33,13 @@ int64_t replay_get_qword(void);
void replay_get_array(uint8_t *buf, size_t *size);
void replay_get_array_alloc(uint8_t **buf, size_t *size);
+/* Mutex functions for protecting replay log file */
+
+void replay_mutex_init(void);
+void replay_mutex_destroy(void);
+void replay_mutex_lock(void);
+void replay_mutex_unlock(void);
+
/*! Checks error status of the file. */
void replay_check_error(void);
- [Qemu-devel] [RFC PATCH v10 00/24] Deterministic replay core, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 01/24] i386: partial revert of interrupt poll fix, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 02/24] replay: global variables and function stubs, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 03/24] sysemu: system functions for replay, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 04/24] replay: internal functions for replay log, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 05/24] replay: introduce mutex to protect the replay log,
Pavel Dovgalyuk <=
- [Qemu-devel] [RFC PATCH v10 06/24] replay: introduce icount event, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 07/24] cpu-exec: allow temporary disabling icount, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 08/24] cpu: replay instructions sequence, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 09/24] i386: interrupt poll processing, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 11/24] replay: asynchronous events infrastructure, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 10/24] replay: interrupts and exceptions, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 13/24] timer: replace time() with QEMU_CLOCK_HOST, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 12/24] replay: recording and replaying clock ticks, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 14/24] replay: shutdown event, Pavel Dovgalyuk, 2015/02/27
- [Qemu-devel] [RFC PATCH v10 15/24] replay: checkpoints, Pavel Dovgalyuk, 2015/02/27