In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to understand SIGALRM signals, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
SIGALRM signal is one of the signals in the operating system. Its function is to set how often the process will receive a SIGALRM signal. Let's take a look at his implementation principle.
The alarm system call is a function that sets how long the SIGALRM signal is triggered. Here is his statement.
# include
Unsigned alarm (unsigned seconds)
Let's see how it works.
Int sys_alarm (long seconds)
{
Int old = current- > alarm
/ / calculate the original time
If (old)
Old = (old-jiffies) / HZ
/ *
The system triggers a clock interrupt every n seconds. Jiffies is the number of clock interruptions that have occurred in the system.
1 second is equal to HZ jiffies. Here, the number of jiffies is calculated, that is, how many times the clock interrupt occurs and then the SIGALRM signal is triggered.
, /
Current- > alarm = (seconds > 0)? (jiffies+HZ*seconds): 0
/ / return to the old
Return (old)
}
We see that the alarm field in PCB records the time when the SIGALRM signal was triggered. Let's take another look at the timing of the trigger.
, /
Void schedule (void)
{
Int i,next,c
Struct task_struct * * p
/ / traversing the process
For (p = & LAST_TASK; p > & FIRST_TASK;-- p)
If (* p) {
/ *
Determine if alarm is set and expired
Alarm
< jiffies说明过期了。设置alarm信号,清除设置标记 */ if ((*p)->Alarm & & (* p)-> alarm
< jiffies) { (*p)->Signal | = (1)
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.