mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 10:24:59 +00:00
Kernel: Do timekeeping manually instead of asking the RTC all the time.
This introduces a tiny amount of timer drift which I will have to fix somehow eventually, but it's a huge improvement in timing consistency as we no longer suddenly jump from e.g 10:45:49.123 to 10:45:50.000.
This commit is contained in:
parent
20f7d7ec67
commit
ab11f42094
5 changed files with 34 additions and 21 deletions
|
@ -55,15 +55,15 @@ bool Scheduler::pick_next()
|
|||
return context_switch(s_colonel_process->main_thread());
|
||||
}
|
||||
|
||||
auto now_sec = RTC::now();
|
||||
auto now_usec = (suseconds_t)((PIT::ticks_since_boot() % 1000) * 1000);
|
||||
struct timeval now;
|
||||
kgettimeofday(now);
|
||||
auto now_sec = now.tv_sec;
|
||||
auto now_usec = now.tv_usec;
|
||||
|
||||
// Check and unblock threads whose wait conditions have been met.
|
||||
Thread::for_each([&] (Thread& thread) {
|
||||
auto& process = thread.process();
|
||||
|
||||
// dbgprintf("pick_next, checking on %s(%u:%u) in state %s\n", process.name().impl()->characters(), process.pid(), thread.tid(), to_string(thread.state()));
|
||||
|
||||
if (thread.state() == Thread::BlockedSleep) {
|
||||
if (thread.wakeup_time() <= system.uptime)
|
||||
thread.unblock();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue