Having the understanding of HZ, jiffies, and system timer, it is appropriate to discuss the implementation of time management. Most of the jobs in time management are handled by a dedicated function called timer handler. In Microblaze, the kernel registers timer_interrupt as the interrupt handler:

irqreturn_t TIMER_TEXT timer_interrupt(int irq, void *dev_id)

When kernel is executing timer handler, the timer is first acknowledged, followed by obtaining the xtime_lock lock, which protects access to jiffies and the wall time value, xtime. Most of the important work is performed in do_timer and update_process_times. The former is responsible in performing the increment of jiffies, updating the wall time in accordance with the elapsed ticks and also updating the system’s load average statistics.

update_process_times is executed when do_timer returned. It’s role is to update various statistics that a tick has elapsed. Besides process accounting, it decrements the currently running process’s time slice and determine whether there is need for reschedule. profile_tick is used to identify the hot spots of the kernel code and enabling the code profiler. Finally, xtime_lock is released and the handler returned with IRQ_HANDLED, which is defined as 1 to show that the handler is executed successfully.