In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The timer in the software sense finally depends on the hardware timer. The kernel detects whether each timer expires after the occurrence of the clock interrupt, and the timer processing function after expiration will be executed in the bottom half as a soft interrupt. In essence, the clock interrupt handler replaces TIMER_SOFTIRQ soft interrupts and runs all timers that expire on the current processor.
To sum up, it is still the process of soft interrupt.
a. Register the soft interrupt handler
/ * / linux/kernel.timer.c*/void _ init init_timers (void)-- > open_softirq (TIMER_SOFTIRQ, run_timer_softirq, NULL)
b. Add timer_list to a linked list
Void add_timer (struct timer_list * timer)
c. Trigger soft interrupt handler function
Void irq_exit (void)-> tick_nohz_stop_sched_tick ();-> raise_softirq_irqoff (TIMER_SOFTIRQ)
d. Call soft interrupt handling function
Static void run_timer_softirq (struct softirq_action * h)
-- > _ _ run_timers (base)
-- > iterate through the timer handler in the timer_list where the execution time arrives
In Linux device driver programming, a set of functions and data structures provided in the Linux kernel can be used to complete timing trigger work or complete some periodic transactions. This set of functions and data structures make it unnecessary for drivers to worry about the kernel and hardware behavior of specific software timers in most cases.
1) an instance of timer_list structure corresponds to a timer, which is defined as follows:
Struct timer_list {struct list_head entry, / * timer list * / unsigned long expires, / * timer expiration time * / void (* function) (unsigned long), / * timer handler * / unsigned long data,/* is passed as parameters to timer handler * / struct timer_base_s * base,.}
Instantiate struct timer_list my_timer
2) initialize timer
Void init_timer (struct timer_list * timer); TIMER_INITIALIZER (_ function, _ expires, _ data) DEFINE_TIMER (_ name, _ function, _ expires, _ data) setup_timer ()
3) add timer
Void add_timer (struct timer_list * timer)
4) delete timer
Int del_timer (struct timer_list * timer)
5) modify the expire of the timer
Int mod_timer (struct timer_list * timer, unsigned long expires)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.