From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LltPL-0005eO-Vu for qemu-devel@nongnu.org; Mon, 23 Mar 2009 19:18:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LltPG-0005Zf-U4 for qemu-devel@nongnu.org; Mon, 23 Mar 2009 19:18:15 -0400 Received: from [199.232.76.173] (port=38767 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LltPG-0005ZY-Pr for qemu-devel@nongnu.org; Mon, 23 Mar 2009 19:18:10 -0400 Received: from mx20.gnu.org ([199.232.41.8]:9225) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LltPG-0008Di-I1 for qemu-devel@nongnu.org; Mon, 23 Mar 2009 19:18:10 -0400 Received: from mx2.redhat.com ([66.187.237.31]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LltPF-0005vE-DY for qemu-devel@nongnu.org; Mon, 23 Mar 2009 19:18:09 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n2NNI6pD012877 for ; Mon, 23 Mar 2009 19:18:08 -0400 Date: Mon, 23 Mar 2009 20:17:56 -0300 From: Marcelo Tosatti Subject: Re: [Qemu-devel] [patch 1/7] qemu: mutex/thread/cond wrappers Message-ID: <20090323231756.GA4626@amt.cnet> References: <20090319145705.988576615@localhost.localdomain> <20090319150537.801001000@localhost.localdomain> <49C26BE9.4030905@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49C26BE9.4030905@redhat.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Avi Kivity 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.