4/30/2023 0 Comments Suspend itimer while in handlerFinally, calc_load() is called to update the load average and update_times() returns. The wall_jiffies value is increased by the ticks valuethus, it is equal to the jiffies value of the most recent wall time updateand update_wall_time() is called to update xtime, which stores the wall time. It is not the norm and quite often a bug. This can occur if interrupts are off for a long time. In rare situations, timer interrupts can be missed and the ticks are said to be lost. In normal cases, this is, of course, one. The ticks value is calculated to be the change in ticks since the last update. When update_process_times() returns, do_timer() calls update_times() to update the wall time: On SMP machines, it also balances the per-processor runqueues as needed. Timers are covered in a following section, " Timers."įinally, the scheduler_tick() function decrements the currently running process's timeslice and sets need_resched if needed. Next, the run_local_timers() function marks a softirq (see Chapter 7, "Bottom Halves and Deferring Work") to handle the execution of any expired timers. It is also another reason for a higher frequency tick rate. In fact, the process might not even have been the only process running in the last tick! This granular process accounting is classic Unix, and without much more complex accounting, this is the best the kernel can provide. In reality, the process might have entered and exited kernel mode many times during the last tick. You might realize that this implies that the kernel credits a process for running the entire previous tick in whatever mode the processor was in when the timer interrupt occurred. The appropriate value is increased by one and the other value remains the same. * update by one jiffy the appropriate time counter Therefore, updates_one_process() can simply add each value to the corresponding counter without a branch: It is rather elaborate, but note how one of either the user_tick or the system value is equal to one and the other is zero, because of the exclusive-or (XOR). The update_one_process() function does the actual updating of the process's times. Update_one_process(p, user_tick, system, cpu) ![]() This enables update_process_times() to attribute the previous tick to the proper mode, either user or system: The user_mode() macro looks at the state of the processor registers, regs, and returns one if the timer interrupt occurred in user-space and zero if the interrupt occurred in kernel mode. The actual routine is very simple because other functions handle most of the previously discussed work: Update the wall time, which is stored in xtime Run any dynamic timers that have expired (discussed in the following section)Įxecute scheduler_tick(), as discussed in Chapter 4, "Process Scheduling" Update resource usages, such as consumed system and user time, for the currently running process Increment the jiffies_64 count by one (this is safe, even on 32-bit architectures, because the xtime_lock lock was previously obtained) The architecture-independent routine, do_timer(), performs much more work: Periodically save the updated wall time to the real time clockĬall the architecture-independent timer routine, do_timer() Obtain the xtime_lock lock, which protects access to jiffies_64 and the wall time value, xtimeĪcknowledge or reset the system timer as required Its exact job depends on the given architecture, of course, but most handlers perform at least the following work: The architecture-dependent routine is registered as the interrupt handler for the system timer and, thus, runs when the timer interrupt hits. The timer interrupt is broken into two pieces: an architecture-dependent and an architecture-independent routine. But before it fired on the 60 seconds, user cancel the application by Ctrl+C.Now that we have an understanding of HZ, jiffies, and what the system timer's role is, let's look at the actual implementation of the timer interrupt handler. I want to create a timer and set it to fire only once after 60 seconds.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |