mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-10 22:44:30 +00:00
timer session: add elapsed_us method
As timer sessions are not expected to be microseconds precise (because of RPC latency and scheduling), the session interface provided only a method 'elapsed_ms' although the back end of this method in the timer driver works with microseconds. However, in some cases it makes sense to have a method 'elapsed_us'. The values it returns might be milliseconds away from the "real" time but it allows you to work with delays smaller than a millisecond without getting a zero delta value. This commit is motivated by the need for fast bursts of calibration steps for the time interpolation in the new timer connection. Ref #2400
This commit is contained in:
parent
f7f2c86c41
commit
8750e373a0
@ -34,6 +34,8 @@ struct Timer::Session_client : Genode::Rpc_client<Session>
|
||||
void sigh(Signal_context_capability sigh) override { call<Rpc_sigh>(sigh); }
|
||||
|
||||
unsigned long elapsed_ms() const override { return call<Rpc_elapsed_ms>(); }
|
||||
|
||||
unsigned long elapsed_us() const override { return call<Rpc_elapsed_us>(); }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__TIMER_SESSION__CLIENT_H_ */
|
||||
|
@ -58,6 +58,8 @@ struct Timer::Session : Genode::Session
|
||||
*/
|
||||
virtual unsigned long elapsed_ms() const = 0;
|
||||
|
||||
virtual unsigned long elapsed_us() const = 0;
|
||||
|
||||
/**
|
||||
* Client-side convenience method for sleeping the specified number
|
||||
* of milliseconds
|
||||
@ -79,9 +81,10 @@ struct Timer::Session : Genode::Session
|
||||
GENODE_RPC(Rpc_trigger_periodic, void, trigger_periodic, unsigned);
|
||||
GENODE_RPC(Rpc_sigh, void, sigh, Genode::Signal_context_capability);
|
||||
GENODE_RPC(Rpc_elapsed_ms, unsigned long, elapsed_ms);
|
||||
GENODE_RPC(Rpc_elapsed_us, unsigned long, elapsed_us);
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_trigger_once, Rpc_trigger_periodic,
|
||||
Rpc_sigh, Rpc_elapsed_ms);
|
||||
Rpc_sigh, Rpc_elapsed_ms, Rpc_elapsed_us);
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__TIMER_SESSION__TIMER_SESSION_H_ */
|
||||
|
@ -71,8 +71,11 @@ class Timer::Session_component : public Genode::Rpc_object<Session>,
|
||||
}
|
||||
|
||||
unsigned long elapsed_ms() const override {
|
||||
return (_timeout_scheduler.curr_time().trunc_to_plain_us().value -
|
||||
_init_time_us) / 1000; }
|
||||
return elapsed_us() / 1000; }
|
||||
|
||||
unsigned long elapsed_us() const override {
|
||||
return _timeout_scheduler.curr_time().trunc_to_plain_us().value -
|
||||
_init_time_us; }
|
||||
|
||||
void msleep(unsigned) override { /* never called at the server side */ }
|
||||
void usleep(unsigned) override { /* never called at the server side */ }
|
||||
|
Loading…
x
Reference in New Issue
Block a user