lkml.org 
[lkml]   [2015]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH 21/28] lkl tools: host lib: posix host operations
From
On Sun, Nov 8, 2015 at 1:16 AM, Arnd Bergmann <arnd@arndb.de> 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 !


\
 
 \ /
  Last update: 2015-11-08 05:21    [W:0.626 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site