[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: qemu_coroutine_yield switches thread?
From: |
Dietmar Maurer |
Subject: |
Re: qemu_coroutine_yield switches thread? |
Date: |
Thu, 16 Apr 2020 12:09:34 +0200 (CEST) |
> > quick question: Can a resume from a qemu_coroutine_yield happen in a
> > different thread?
> >
> > Well, it can, since I'm seeing it happen, but is that okay or a bug?
>
> Yes, it can happen. At least for devices like IDE where a request is
> started during a vmexit (MMIO or I/O port write), the coroutine will
> usually begin its life in the vcpu thread and then move to the main loop
> thread.
>
> This is not a problem because the vcpu thread holds the BQL while
> running the request coroutine.
Isn't that a problem when using QemuRecMutex, for example:
qemu_rec_mutex_lock(lock)
...
qemu_coroutine_yield() // wait for something
// we are now inside a different thread
qemu_rec_mutex_unlock(lock) // Crash - wrong thread!!
?