Second Extended Filesystem (ext2) and other improvements (#33)
[lunaix-os.git] / lunaix-os / kernel / time / timer.c
index 8f368df59ce83889f6b2ccbef65fbf1456e1a37a..b9d98afc8b79d7cb912f3f7092020e1e21a6ed32 100644 (file)
@@ -9,7 +9,6 @@
  * @copyright Copyright (c) 2022
  *
  */
-#include <sys/interrupts.h>
 
 #include <lunaix/mm/cake.h>
 #include <lunaix/mm/valloc.h>
@@ -17,6 +16,7 @@
 #include <lunaix/spike.h>
 #include <lunaix/syslog.h>
 #include <lunaix/timer.h>
+#include <lunaix/hart_state.h>
 
 #include <hal/hwtimer.h>
 
@@ -54,7 +54,7 @@ timer_init()
 
     timer_ctx->base_frequency = hwtimer_base_frequency();
 
-    sched_ticks = SYS_TIMER_FREQUENCY_HZ / 1000 * SCHED_TIME_SLICE;
+    sched_ticks = (SYS_TIMER_FREQUENCY_HZ * SCHED_TIME_SLICE) / 1000;
     sched_ticks_counter = 0;
 }
 
@@ -123,6 +123,7 @@ timer_update()
 
     if (sched_ticks_counter >= sched_ticks) {
         sched_ticks_counter = 0;
+        thread_stats_update_entering(false);
         schedule();
     }
 }