Re: [RFC PATCH 21/28] lkl tools: host lib: posix host operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux