Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933143AbbKGXQw (ORCPT ); Sat, 7 Nov 2015 18:16:52 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:58970 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933091AbbKGXQu (ORCPT ); Sat, 7 Nov 2015 18:16:50 -0500 From: Arnd Bergmann To: Octavian Purdila Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, thehajime@gmail.com Subject: Re: [RFC PATCH 21/28] lkl tools: host lib: posix host operations Date: Sun, 08 Nov 2015 00:16:40 +0100 Message-ID: <42449799.QsmXDGnQ4P@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1446582059-17355-22-git-send-email-octavian.purdila@intel.com> References: <1446582059-17355-1-git-send-email-octavian.purdila@intel.com> <1446582059-17355-22-git-send-email-octavian.purdila@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:T9FnIkLPBfBeaOgLV95RsXQs0/sjsajxaPlyMwiwZz0fPh7vmFm QqN58ejzNju7IG5XJk+Da5++mxqqlohPnNhcH3ekbJ8vRxKxatGkcHmgsQaPYodowLznxyU ZuYRfan7hFFgIY4wWzA9ZE49x+GdMbA5sn3NGbSecg14TlLNdotrRAC1b19szDCOeH7YNeo nzihClp9oSSSF/z+casAA== X-UI-Out-Filterresults: notjunk:1;V01:K0:BMgZmpvLrQE=:5yvn91Vhou7M8AF9qQoilf fEoz8zcmcZZXNHPOJ6UlkJzh3KESehziAyastPptrYnIoPjG9osNCUI3IHG1PLo5VB9UpQYvk jMJTST6qRgwDc+WMIbWz3p1xRRC/YDVQZyG8rMP8cmDE/9fsyL0+0RjAtGTXMGKnjZxqU6KfA 2iASsurs0sppZauQQgfp6kqIDnjHpp1bIIWOX07mm7pDUtXmZ3cujqBJlNmqAmdO/6/34K08Y RBP+TzqQ5wf8Xbrdlr5Qz45CT2aqOKzMCq/fLnhi9TIrGbHM6FstWDY8O+bOUInKxpWUCBp7d qzK/r/1tvQnAJh/BJjqb93HhYTTinUh9o5Dvdl0lngNGe6FZCtwGGdks3xKcCus6gq1haxANK 5nSrE1lcOLcrimc5/0RHOfY04cGlQEOCkDoFJKrC3MRm+iW9a11/nFuZ6f48CqH04fvBmck4c qkuMhZOhT86MsPeRcEbx4bKu6+imcHhHKepsp+ZoYqyvph5aftXXYO4MIVDk2NajyIG+/Zi6+ MuLFDrOsitBBbI/E8fOJqawCVRwyfehmqI+57kVSj6glQ09Oqenx8rD6H+qvYH0Rqo/PmROts grjr/DArzB2x0X+DIM1w0MWyPXq67rLi5qzKaLv6bVTfqIFnOyG4blt7QOatGkrh3+cy/g+Ik nqjGllQvHzf6E2Iki6IC7hKs6XuhPgvE+Eh8zl7MiybEpkkWmZN7RXpX6T8n/4m907uMCRTGq bVUy8cDPupiUOYuY Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1075 Lines: 43 On Tuesday 03 November 2015 22:20:52 Octavian Purdila wrote: > +struct pthread_sem { > + pthread_mutex_t lock; > + int count; > + pthread_cond_t cond; > +}; > + > +static void *sem_alloc(int count) > +{ > + struct pthread_sem *sem; > + > + sem = malloc(sizeof(*sem)); > + if (!sem) > + return NULL; > + > + pthread_mutex_init(&sem->lock, NULL); > + sem->count = count; > + pthread_cond_init(&sem->cond, NULL); > + > + return sem; > +} What is the reason to have generalized semaphores in the host API rather than a simple mutex? > +static unsigned long long time_ns(void) > +{ > + struct timeval tv; > + > + gettimeofday(&tv, NULL); > + > + return tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000ULL; > +} clock_gettime() has been around since POSIX.1-2001 and provides the nanosecond resolution you use in the interface. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/