[Top][All Lists]

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

Re: [Qemu-devel] [RFC v2 3/5] timer: make qemu_clock_enable sync between

From: Paolo Bonzini
Subject: Re: [Qemu-devel] [RFC v2 3/5] timer: make qemu_clock_enable sync between disable and timer's cb
Date: Mon, 29 Jul 2013 13:21:40 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

Il 29/07/2013 10:10, liu ping fan ha scritto:
> On Mon, Jul 29, 2013 at 2:30 PM, Paolo Bonzini <address@hidden> wrote:
>> Il 29/07/2013 05:16, Liu Ping Fan ha scritto:
>>> After disabling the QemuClock, we should make sure that no QemuTimers
>>> are still in flight. To implement that, the caller of disabling will
>>> wait until the last user's exit.
>>> Note, the callers of qemu_clock_enable() should be sync by themselves,
>>> not protected by this patch.
>>> Signed-off-by: Liu Ping Fan <address@hidden>
>> This is an interesting approach.
>>> -    if (!clock->enabled)
>>> -        return;
>>> +    atomic_inc(&clock->using);
>>> +    if (unlikely(!clock->enabled)) {
>>> +        goto exit;
>>> +    }
>> This can return directly, it doesn't need to increment and decrement
>> clock->using.
> Here is a race condition like the following

Ah, I see.

Still this seems a bit backwards.  Most of the time you will have no one
on the wait_using condvar, but you are almost always signaling the
condvar (should be broadcast BTW)...


reply via email to

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