L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
poll_timeout_kipclock
1// vi:set ft=cpp: -*- Mode: C++ -*-
2/*
3 * (c) 2012 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
4 * economic rights: Technische Universität Dresden (Germany)
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU Lesser General Public License 2.1.
7 * Please see the COPYING-LGPL-2.1 file for details.
8 */
9#pragma once
10
11#include <cassert>
12#include <l4/sys/kip.h>
13#include <l4/re/env.h>
14
15namespace L4 {
16
39{
40public:
45 Poll_timeout_kipclock(unsigned poll_time_us)
46 {
47 set(poll_time_us);
48 }
49
54 void set(unsigned poll_time_us)
55 {
56 _timeout = l4_kip_clock(l4re_kip()) + poll_time_us;
57 _last_check = true;
58 }
59
68 bool test(bool expression = true)
69 {
70 if (!expression)
71 return false;
72
73 return _last_check = l4_kip_clock(l4re_kip()) < _timeout;
74 }
75
80 bool timed_out() const { return !_last_check; }
81
82private:
83 l4_cpu_time_t _timeout;
84 bool _last_check;
85};
86}
A polling timeout based on the L4Re clock.
Poll_timeout_kipclock(unsigned poll_time_us)
Initialise relative timeout in microseconds.
bool test(bool expression=true)
Test whether timeout has expired.
void set(unsigned poll_time_us)
(Re-)Set relative timeout in microseconds
bool timed_out() const
Query whether timeout has expired.
Environment interface.
l4_kernel_info_t const * l4re_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition env.h:194
l4_uint64_t l4_cpu_time_t
CPU clock type.
Definition l4int.h:58
l4_cpu_time_t l4_kip_clock(l4_kernel_info_t const *kip) L4_NOTHROW
Return clock value from the KIP.
Definition kip.h:215
L4 low-level kernel interface.
Kernel Info Page access functions.