|
|
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.
|
|