MCPcopy Create free account
hub / github.com/Starry-OS/StarryOS / poll

Method poll

core/src/time.rs:169–186  ·  view source on GitHub ↗

Polls the time manager to update the timers and emit signals if necessary.

(&mut self, emitter: impl Fn(Signo))

Source from the content-addressed store, hash-verified

167 /// Polls the time manager to update the timers and emit signals if
168 /// necessary.
169 pub fn poll(&mut self, emitter: impl Fn(Signo)) {
170 let now_ns = monotonic_time_nanos() as usize;
171 let delta = now_ns - self.last_wall_ns;
172 match self.state {
173 TimerState::User => {
174 self.utime_ns += delta;
175 self.update_itimer(ITimerType::Virtual, delta, &emitter);
176 self.update_itimer(ITimerType::Prof, delta, &emitter);
177 }
178 TimerState::Kernel => {
179 self.stime_ns += delta;
180 self.update_itimer(ITimerType::Prof, delta, &emitter);
181 }
182 TimerState::None => {}
183 }
184 self.update_itimer(ITimerType::Real, delta, &emitter);
185 self.last_wall_ns = now_ns;
186 }
187
188 /// Updates the timer state.
189 pub fn set_state(&mut self, state: TimerState) {

Callers 3

poll_timerFunction · 0.45
set_timer_stateFunction · 0.45
ci-test.pyFile · 0.45

Calls 1

update_itimerMethod · 0.80

Tested by

no test coverage detected