From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lm1Hg-00065a-31 for qemu-devel@nongnu.org; Tue, 24 Mar 2009 03:42:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lm1Hb-00065O-Cx for qemu-devel@nongnu.org; Tue, 24 Mar 2009 03:42:51 -0400 Received: from [199.232.76.173] (port=45305 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lm1Hb-00065L-7i for qemu-devel@nongnu.org; Tue, 24 Mar 2009 03:42:47 -0400 Received: from mx2.redhat.com ([66.187.237.31]:57754) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lm1Ha-0000IL-Oy for qemu-devel@nongnu.org; Tue, 24 Mar 2009 03:42:47 -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 n2O7ghcp030139 for ; Tue, 24 Mar 2009 03:42:46 -0400 Message-ID: <49C88F14.7000008@redhat.com> Date: Tue, 24 Mar 2009 09:43:16 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [patch 1/7] qemu: mutex/thread/cond wrappers References: <20090319145705.988576615@localhost.localdomain> <20090319150537.801001000@localhost.localdomain> <49C26BE9.4030905@redhat.com> <20090323231756.GA4626@amt.cnet> In-Reply-To: <20090323231756.GA4626@amt.cnet> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 Marcelo Tosatti wrote: >> and why milliseconds? >> > > Well, its suitable for the current purposes. Any other suggestion? > > uint64_t nanoseconds. It's standard timekeeping in qemu: #define QEMU_TIMER_BASE 1000000000LL and it's of course best to limit the number of standards. >> 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? > Instead of 'sleep until n nanoseconds have elapsed', 'sleep until get_clock() >= deadline'. I think it simplifies things somewhat. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.