qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH qom-cpu 35/59] linux-user: Simplify start_exclusive(


From: Andreas Färber
Subject: [Qemu-devel] [PATCH qom-cpu 35/59] linux-user: Simplify start_exclusive()
Date: Sun, 9 Jun 2013 21:13:02 +0200

Use new qemu_for_each_cpu().

Signed-off-by: Andreas Färber <address@hidden>
---
 linux-user/main.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index 95e17cf..5ced658 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -144,25 +144,24 @@ static inline void exclusive_idle(void)
     }
 }
 
+static void start_exclusive_stop_one(CPUState *cpu, void *data)
+{
+    if (cpu->running) {
+        pending_cpus++;
+        cpu_exit(cpu);
+    }
+}
+
 /* Start an exclusive operation.
    Must only be called from outside cpu_arm_exec.   */
 static inline void start_exclusive(void)
 {
-    CPUArchState *other;
-    CPUState *other_cpu;
-
     pthread_mutex_lock(&exclusive_lock);
     exclusive_idle();
 
     pending_cpus = 1;
     /* Make all other cpus stop executing.  */
-    for (other = first_cpu; other; other = other->next_cpu) {
-        other_cpu = ENV_GET_CPU(other);
-        if (other_cpu->running) {
-            pending_cpus++;
-            cpu_exit(other_cpu);
-        }
-    }
+    qemu_for_each_cpu(start_exclusive_stop_one, NULL);
     if (pending_cpus > 1) {
         pthread_cond_wait(&exclusive_cond, &exclusive_lock);
     }
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]