Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754245AbbKHEBP (ORCPT ); Sat, 7 Nov 2015 23:01:15 -0500 Received: from mail-wi0-f179.google.com ([209.85.212.179]:35985 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752669AbbKHEBK (ORCPT ); Sat, 7 Nov 2015 23:01:10 -0500 MIME-Version: 1.0 In-Reply-To: <42449799.QsmXDGnQ4P@wuerfel> References: <1446582059-17355-1-git-send-email-octavian.purdila@intel.com> <1446582059-17355-22-git-send-email-octavian.purdila@intel.com> <42449799.QsmXDGnQ4P@wuerfel> Date: Sun, 8 Nov 2015 06:01:08 +0200 Message-ID: Subject: Re: [RFC PATCH 21/28] lkl tools: host lib: posix host operations From: Octavian Purdila To: Arnd Bergmann Cc: Linux-Arch , lkml , Hajime Tazaki Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1442 Lines: 51 On Sun, Nov 8, 2015 at 1:16 AM, Arnd Bergmann wrote: > 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? > Currently waking up from idle after an IRQ event requires a semaphore. I'll see if we can use a simple mutex for this. >> +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. > Good point, I will change it to clock_gettime. Thanks for the review 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/