Periodically calling a function since system initialization

Viewed 38

Assume I have a per-CPU variable declared with DEFINE_PER_CPU(struct var, var) and associated to each struct var is an attribute int count. This occurs during system initialization and is therefore (assumedly) located in init/main.c. Further assume that I have an increment_count() function defined as

    void increment_count() {
        per_cpu(var, get_cpu()).count += 1;
        put_cpu();
    }

I would like for increment_count to get called by the kernel every x milliseconds, beginning at system initialization. Some jitter in the timing interval is fine. How can this be implemented in practice? Furthermore, do I need to explicitly preempt the currently running thread to allow the increment_count() thread to run?

0 Answers
Related