10 #include "sys/list_head.h"
18 #define ENABLE_REAL_TIMER_SYSTEM
27 #define ITIMER_VIRTUAL 1
33 #define TICKS_PER_SECOND 1193
62 #ifdef ENABLE_REAL_TIMER_SYSTEM
71 #define TVN_SIZE (1 << TVN_BITS)
73 #define TVR_SIZE (1 << TVR_BITS)
75 #define TVN_MASK (TVN_SIZE - 1)
77 #define TVR_MASK (TVR_SIZE - 1)
79 #define TIMER_TICKS_BITS(tv) (TVR_BITS + TVN_BITS * (tv))
81 #define TIMER_TICKS(tv) (1 << TIMER_TICKS_BITS(tv))
91 #ifdef ENABLE_REAL_TIMER_SYSTEM
106 struct list_head list;
117 struct list_head
entry;
121 void (*
function)(
unsigned long);
Kernel generic data structure and functions.
Process data structures and functions.
atomic_t spinlock_t
Spinlock structure.
Definition: spinlock.h:16
Standard integer data-types.
unsigned int uint64_t
Define the unsigned 64-bit integer.
Definition: stdint.h:12
unsigned int uint32_t
Define the unsigned 32-bit integer.
Definition: stdint.h:18
Rappresents a time interval.
Definition: time.h:53
Interrupt stack frame.
Definition: kernel.h:24
this is our task object. Every process in the system has this, and it holds a lot of information....
Definition: process.h:82
Represents the request to execute a function in the future, also known as timer.
Definition: timer.h:113
tvec_base_t * base
Pointer to the structure containing all the other related timers.
Definition: timer.h:125
spinlock_t lock
Protects the access to the timer.
Definition: timer.h:115
struct list_head entry
Lists of timers are mantained using the list_head.
Definition: timer.h:117
unsigned long data
Custom data to be passed to the timer function.
Definition: timer.h:123
unsigned long expires
Ticks value when the timer has to expire.
Definition: timer.h:119
Specify intervals of time with nanosecond precision.
Definition: time.h:59
Contains all the timers of a single CPU.
Definition: timer.h:86
spinlock_t lock
Lock for the timer data structure.
Definition: timer.h:88
list_head tvn[TVN_COUNT][TVN_SIZE]
Definition: timer.h:102
struct timer_list * running_timer
Points to the dynamic timer that is currently handled by the CPU.
Definition: timer.h:90
list_head tvr[TVR_SIZE]
Lists of root timers that will expires in the next 255 ticks.
Definition: timer.h:96
unsigned long timer_ticks
The earliest expiration time of the dynamic timers yet to be checked.
Definition: timer.h:93
#define TVN_COUNT
Number of normal timer vectors.
Definition: timer.h:65
int sys_nanosleep(const struct timespec *req, struct timespec *rem)
Suspends the execution of the calling thread.
Definition: timer.c:603
void init_timer(struct timer_list *timer)
Initializes a new timer struct.
Definition: timer.c:314
void timer_install(void)
Sets up the system clock by installing the timer handler into IRQ0.
Definition: timer.c:111
#define TVN_SIZE
Number of headers in a normal timer vector.
Definition: timer.h:71
uint64_t timer_get_seconds(void)
Returns the number of seconds since the system started its execution.
Definition: timer.c:123
int sys_setitimer(int which, const struct itimerval *new_value, struct itimerval *old_value)
Arms or disarms the timer specified by which, by setting the timer to the value specified by new_valu...
Definition: timer.c:680
#define TVR_SIZE
Number of headers in a root timer vector.
Definition: timer.h:73
void dynamic_timers_install(void)
Initialize dynamic timer system.
Definition: timer.c:451
void remove_timer(struct timer_list *timer)
Removes a timer from the current CPU.
Definition: timer.c:340
unsigned long timer_get_ticks(void)
Returns the number of ticks since the system started its execution.
Definition: timer.c:128
unsigned sys_alarm(int seconds)
Send signal to calling thread after desired seconds.
Definition: timer.c:626
void run_timer_softirq(void)
Updates the timer data structures.
Definition: timer.c:461
void add_timer(struct timer_list *timer)
Add a new timer to the current CPU.
Definition: timer.c:325
void timer_handler(pt_regs *f)
Handles the timer.
Definition: timer.c:93
void timer_phase(const uint32_t hz)
Allows to set the timer phase to the given frequency.
Definition: timer.c:81
int sys_getitimer(int which, struct itimerval *curr_value)
Fills the structure pointed to by curr_value with the current setting for the timer specified by whic...
Definition: timer.c:662
struct tvec_base_s tvec_base_t
Contains all the timers of a single CPU.
void update_process_profiling_timer(task_struct *proc)
Update the profiling timer and generate SIGPROF if it has expired.
Definition: timer.c:733