qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Re: [RFC] queue_work proposal


From: Glauber Costa
Subject: [Qemu-devel] Re: [RFC] queue_work proposal
Date: Thu, 3 Sep 2009 08:07:50 -0300
User-agent: Jack Bauer

On Thu, Sep 03, 2009 at 09:36:09AM +0200, Paolo Bonzini wrote:
>
>> +    env->queued_total++;
>> +
>> +    if (env == qemu_get_current_env()) {
>> +        env->queued_total++;
>
> Why increment twice? (though queued_total is write only and queued_local  
> is unused, so...)
yeah, you got it =p

As I said, I just dumped whatever I had.

>
>> +        func(data);
>> +        return;
>> +    }
>> +
>> +    wii = qemu_mallocz(sizeof(*wii));
>> +    wii->func = func;
>> +    wii->data = data;
>> +    wii->wait = wait;
>> +    TAILQ_INSERT_TAIL(&env->queued_work, wii, entry);
>> +
>> +    qemu_thread_signal(env->thread, SIGUSR1);
>> +
>> +    while (wait&&  !wii->done) {
>> +        qemu_cond_wait(env->work_cond,&qemu_global_mutex);
>> +    }
>
> You need to lock qemu_global_mutex around this while statement, or to  
> add env->queue_mutex and include the TAILQ_INSERT_TAIL in the mutex.
Thanks for catching. The later is clearly preferred , IMHO, for scalability
purposes.





reply via email to

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