qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [patch 1/7] qemu: mutex/thread/cond wrappers


From: Marcelo Tosatti
Subject: Re: [Qemu-devel] [patch 1/7] qemu: mutex/thread/cond wrappers
Date: Mon, 23 Mar 2009 20:17:56 -0300
User-agent: Mutt/1.5.18 (2008-05-17)

On Thu, Mar 19, 2009 at 05:59:37PM +0200, Avi Kivity wrote:
>> +static void add_to_timespec(struct timespec *ts, unsigned int msecs)
>> +{
>> +    ts->tv_sec = ts->tv_sec + (long)(msecs / 1000);
>> +    ts->tv_nsec = (ts->tv_nsec + ((long)msecs % 1000) * 1000000);
>> +    if (ts->tv_nsec >= 1000000000) {
>> +        ts->tv_nsec -= 1000000000;
>> +        ts->tv_sec++;
>> +    }
>> +}
>>   
>
> timespec_add_msec()?  

> and why milliseconds?  

Well, its suitable for the current purposes. Any other suggestion?

> Also, maybe uint64_t is a  better type.

>> +
>> +int qemu_mutex_timedlock(QemuMutex *mutex, unsigned int msecs)
>> +{
>> +    struct timespec ts;
>> +
>> +    clock_gettime(CLOCK_REALTIME, &ts);
>> +    add_to_timespec(&ts, msecs);
>> +
>> +    return pthread_mutex_timedlock(&mutex->lock, &ts);
>> +}
>>   
>
> I would have preferred a deadline instead of a timeout, but we'll see on  
> the next patches.

Please expand?

Fixed the other comments, thanks.





reply via email to

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