Ejemplo n.º 1
0
Archivo: ntk-perf.C Proyecto: 0mk/non
unsigned long long get_ts ( void )
{
    struct timeval then;
    gettimeofday( &then, NULL );

    return tv_to_ts( &then );
}
Ejemplo n.º 2
0
static int rd_timedlock(pthread_rwlock_t *lock, int timeout)
{
	tv_t now;
	ts_t abs;
	int ret;

	tv_time(&now);
	tv_to_ts(&abs, &now);
	abs.tv_sec += timeout;

	ret = pthread_rwlock_timedrdlock(lock, &abs);

	return ret;
}
Ejemplo n.º 3
0
int _mutex_timedlock(mutex_t *lock, int timeout, const char *file, const char *func, const int line)
{
	tv_t now;
	ts_t abs;
	int ret;

	tv_time(&now);
	tv_to_ts(&abs, &now);
	abs.tv_sec += timeout;

	ret = pthread_mutex_timedlock(&lock->mutex, &abs);
	if (!ret) {
		lock->file = file;
		lock->func = func;
		lock->line = line;
	}

	return ret;
}
Ejemplo n.º 4
0
int _cksem_mswait(sem_t *sem, int ms, const char *file, const char *func, const int line)
{
	ts_t abs_timeout, ts_now;
	tv_t tv_now;
	int ret;

	tv_time(&tv_now);
	tv_to_ts(&ts_now, &tv_now);
	ms_to_ts(&abs_timeout, ms);
	timeraddspec(&abs_timeout, &ts_now);
	ret = sem_timedwait(sem, &abs_timeout);

	if (ret) {
		if (likely(errno == ETIMEDOUT))
			return ETIMEDOUT;
		if (errno == EINTR)
			return EINTR;
		quitfrom(1, file, func, line, "Failed to sem_timedwait errno=%d sem=0x%p", errno, sem);
	}
	return 0;
}