base: use Mutex/Blockade

Issue #3612
This commit is contained in:
Alexander Boettcher
2020-02-19 16:26:40 +01:00
committed by Christian Helmuth
parent e87d60ddf7
commit 3956530634
50 changed files with 370 additions and 374 deletions

View File

@ -68,14 +68,14 @@ static l4_timeout_s mus_to_timeout(uint64_t mus)
Microseconds Timer::Time_source::max_timeout() const
{
Genode::Lock::Guard lock_guard(_lock);
Genode::Mutex::Guard lock_guard(_mutex);
return Microseconds(1000 * 1000 * 100);
}
Duration Timer::Time_source::curr_time()
{
Genode::Lock::Guard lock_guard(_lock);
Genode::Mutex::Guard mutex_guard(_mutex);
static Genode::Attached_rom_dataspace kip_ds(_env, "l4v2_kip");
static Fiasco::l4_kernel_info_t * const kip =
kip_ds.local_addr<Fiasco::l4_kernel_info_t>();

View File

@ -21,7 +21,7 @@ using namespace Genode;
void Timer::Time_source::schedule_timeout(Microseconds duration,
Timeout_handler &handler)
{
Genode::Lock::Guard lock_guard(_lock);
Mutex::Guard mutex_guard(_mutex);
Threaded_time_source::handler(handler);
_next_timeout_us = duration.value;
}
@ -31,9 +31,9 @@ void Timer::Time_source::_wait_for_irq()
{
enum { SLEEP_GRANULARITY_US = 1000 };
uint64_t last_time_us = curr_time().trunc_to_plain_us().value;
_lock.lock();
_mutex.acquire();
while (_next_timeout_us > 0) {
_lock.unlock();
_mutex.release();
try { _usleep(SLEEP_GRANULARITY_US); }
catch (Blocking_canceled) { }
@ -42,11 +42,11 @@ void Timer::Time_source::_wait_for_irq()
uint64_t sleep_duration_us = curr_time_us - last_time_us;
last_time_us = curr_time_us;
_lock.lock();
_mutex.acquire();
if (_next_timeout_us >= sleep_duration_us)
_next_timeout_us -= sleep_duration_us;
else
break;
}
_lock.unlock();
_mutex.release();
}

View File

@ -31,9 +31,9 @@ class Timer::Time_source : public Threaded_time_source
Genode::Env &_env;
Genode::Lock mutable _lock { };
uint64_t _curr_time_us = 0;
uint64_t _next_timeout_us = max_timeout().value;
Genode::Mutex mutable _mutex { };
uint64_t _curr_time_us = 0;
uint64_t _next_timeout_us = max_timeout().value;
void _usleep(uint64_t us);