summary refs log tree commit diff stats
path: root/system/main.c
diff options
context:
space:
mode:
authorPierrick Bouvier <pierrick.bouvier@linaro.org>2025-05-15 10:46:41 -0700
committerRichard Henderson <richard.henderson@linaro.org>2025-05-28 08:07:59 +0100
commit556d05d1e2ac687463ce2877cb4acd1b0589deed (patch)
tree66be9cf4f2b822b82653dd980802e5ea53b37ede /system/main.c
parent319b0c8d077401f51bf6314039b82db20d5267ee (diff)
downloadfocaccia-qemu-556d05d1e2ac687463ce2877cb4acd1b0589deed.tar.gz
focaccia-qemu-556d05d1e2ac687463ce2877cb4acd1b0589deed.zip
system/main: comment lock rationale
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250515174641.4000309-1-pierrick.bouvier@linaro.org>
Diffstat (limited to '')
-rw-r--r--system/main.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/system/main.c b/system/main.c
index 1c02206734..b8f7157cc3 100644
--- a/system/main.c
+++ b/system/main.c
@@ -69,8 +69,21 @@ int (*qemu_main)(void) = os_darwin_cfrunloop_main;
 int main(int argc, char **argv)
 {
     qemu_init(argc, argv);
+
+    /*
+     * qemu_init acquires the BQL and replay mutex lock. BQL is acquired when
+     * initializing cpus, to block associated threads until initialization is
+     * complete. Replay_mutex lock is acquired on initialization, because it
+     * must be held when configuring icount_mode.
+     *
+     * On MacOS, qemu main event loop runs in a background thread, as main
+     * thread must be reserved for UI. Thus, we need to transfer lock ownership,
+     * and the simplest way to do that is to release them, and reacquire them
+     * from qemu_default_main.
+     */
     bql_unlock();
     replay_mutex_unlock();
+
     if (qemu_main) {
         QemuThread main_loop_thread;
         qemu_thread_create(&main_loop_thread, "qemu_main",