Move timer from os to base repository

Since the timer and timeout handling is part of the base library (the
dynamic linker), it belongs to the base repository.

Besides moving the timer and its related infrastructure (alarm, timeout
libs, tests) to the base repository, this patch also moves the timer
from the 'drivers' subdirectory directly to 'src' and disamibuates the
timer's build locations for the various kernels. Otherwise the different
timer implementations could interfere with each other when using one
build directory with multiple kernels.

Note that this patch changes the include paths for the former os/timer,
os/alarm.h, os/duration.h, and os/timed_semaphore.h to base/.

Issue #3101
This commit is contained in:
Norman Feske
2019-01-03 18:01:49 +01:00
parent 14cd115c82
commit bf62d6b896
222 changed files with 272 additions and 454 deletions

View File

@ -0,0 +1,9 @@
TARGET = linux_timer_drv
GEN_DIR := $(call select_from_repositories,src/timer/periodic)/..
INC_DIR += $(GEN_DIR)/periodic
SRC_CC += periodic/time_source.cc time_source.cc
LIBS += syscall-linux
include $(GEN_DIR)/target.inc
vpath periodic/time_source.cc $(GEN_DIR)

View File

@ -0,0 +1,52 @@
/*
* \brief Time source that uses sleeping by the means of the kernel
* \author Norman Feske
* \author Martin Stein
* \date 2006-08-15
*/
/*
* Copyright (C) 2006-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Linux includes */
#include <linux_syscalls.h>
#include <sys/time.h>
/* local includes */
#include <time_source.h>
using namespace Genode;
inline int lx_gettimeofday(struct timeval *tv, struct timeval *tz) {
return lx_syscall(SYS_gettimeofday, tv, tz); }
Microseconds Timer::Time_source::max_timeout() const
{
Lock::Guard lock_guard(_lock);
return Microseconds(1000 * 1000);
}
Duration Timer::Time_source::curr_time()
{
struct timeval tv;
lx_gettimeofday(&tv, 0);
return Duration(Microseconds(tv.tv_sec * 1000 * 1000 + tv.tv_usec));
}
void Timer::Time_source::_usleep(unsigned long us)
{
struct timespec ts;
ts.tv_sec = us / (1000 * 1000);
ts.tv_nsec = (us % (1000 * 1000)) * 1000;
if (lx_nanosleep(&ts, &ts) != 0)
throw Blocking_canceled();
}