Преглед изворни кода

Kernel: Add TimeManagement::now_as_timeval()

Hide the implementation of time-of-day computation in TimeManagement.
Andreas Kling пре 5 година
родитељ
комит
2d35810e0a
3 измењених фајлова са 8 додато и 2 уклоњено
  1. 1 2
      Kernel/Scheduler.cpp
  2. 5 0
      Kernel/Time/TimeManagement.cpp
  3. 2 0
      Kernel/Time/TimeManagement.h

+ 1 - 2
Kernel/Scheduler.cpp

@@ -597,8 +597,7 @@ void Scheduler::timer_tick(const RegisterState& regs)
 
 
     ++g_uptime;
     ++g_uptime;
 
 
-    g_timeofday.tv_sec = TimeManagement::the().epoch_time();
-    g_timeofday.tv_usec = TimeManagement::the().ticks_this_second() * 1000;
+    g_timeofday = TimeManagement::now_as_timeval();
 
 
     if (Process::current->is_profiling()) {
     if (Process::current->is_profiling()) {
         SmapDisabler disabler;
         SmapDisabler disabler;

+ 5 - 0
Kernel/Time/TimeManagement.cpp

@@ -115,6 +115,11 @@ TimeManagement::TimeManagement(bool probe_non_legacy_hardware_timers)
     ASSERT_NOT_REACHED();
     ASSERT_NOT_REACHED();
 }
 }
 
 
+timeval TimeManagement::now_as_timeval()
+{
+    return { s_time_management->epoch_time(), (suseconds_t)s_time_management->ticks_this_second() * (suseconds_t)1000 };
+}
+
 Vector<HardwareTimer*> TimeManagement::scan_and_initialize_periodic_timers()
 Vector<HardwareTimer*> TimeManagement::scan_and_initialize_periodic_timers()
 {
 {
     bool should_enable = is_hpet_periodic_mode_allowed();
     bool should_enable = is_hpet_periodic_mode_allowed();

+ 2 - 0
Kernel/Time/TimeManagement.h

@@ -60,6 +60,8 @@ public:
 
 
     static bool is_hpet_periodic_mode_allowed();
     static bool is_hpet_periodic_mode_allowed();
 
 
+    static timeval now_as_timeval();
+
 private:
 private:
     explicit TimeManagement(bool probe_non_legacy_hardware_timers);
     explicit TimeManagement(bool probe_non_legacy_hardware_timers);
     bool probe_and_set_legacy_hardware_timers();
     bool probe_and_set_legacy_hardware_timers();