Nucleus
Barry CPU specific segment c738dbb (3 years, 2 months ago)
/*
* This file controls the system clock and contains the functions related to
* getting and setting the time from various sources. It keeps a monotonic
* clock internally, but can also make use of the tasks' clocks, and the RTC.
*/
#include <stdint.h>
#include <nucleus/cpu.h>
#include <nucleus/task.h>
uint32_t monotonic = 0;
uint8_t slice[MAX_CPUS] = {0};
/* Timer interrupt */
void
timer_handler(struct InterruptFrame *frame)
{
if (cpu->id == 0)
monotonic++;
if (!current)
return;
slice[cpu->id]++;
/* Call scheduler */
if (slice[cpu->id] < (current->priority * 10))
return;
slice[cpu->id] = 0;
schedule();
}