qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] thread-win32: fix GetThreadContext() permanentl


From: Ян Завадовский
Subject: Re: [Qemu-devel] [PATCH] thread-win32: fix GetThreadContext() permanently fails
Date: Tue, 23 Jun 2015 13:11:27 +0300

On Tue, Jun 23, 2015 at 12:49 PM, Fabien Chouteau <address@hidden> wrote:
Maybe we can, but the "while" will only loop when threads are running on
different CPU, so the other thread is already running and calling sleep
will not help I think.
What you think about this:
diff --git a/cpus.c b/cpus.c
index 83d5eb5..2e71221 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1097,8 +1097,10 @@ static void qemu_cpu_kick_thread(CPUState *cpu)
          * suspended until we can get the context.
          */
         tcgContext.ContextFlags = CONTEXT_CONTROL;
-        while (GetThreadContext(cpu->hThread, &tcgContext) == 0) {
-            continue;
+        if (GetThreadContext(cpu->hThread, &tcgContext) == 0) {
+            fprintf(stderr, "qemu:%s: GetLastError:%lu\n", __func__,
+                    GetLastError());
+            exit(1);
         }

         cpu_signal(0);
Without THREAD_GET_CONTEXT flag this code instantly fails with error message.
So if GetThreadContext will fail sometime in future we will get useful stderr.txt.
Also GetThreadContext is synchronized function(at least this is wrotten by authoritative MS man - see the link from my previous post). No need to ping GetThreadContext until it works.
 
Yan, if you didn't already, I recommend you extensively test this
modification. By extensively, I mean running QEMU several thousands of
time on an SMP host (with many CPUs like 8 or 16 if possible).
Temporarily now I have only my home 4-cores CPU.
But this mistake I found in March. Fix it and run Qemu many times. Mostly with OVMF BIOS.


reply via email to

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