High resource usage of the Program System

Source: Internet
Author: User
The resource usage of the program system is too high-Linux general technology-Linux programming and kernel information. The following is a detailed description. 15:38:31% usr % sys % wio % idle (-u)
15:38:32 0 0 100
15:38:33 0 0 100
15:38:34 0 4 58 38
15:38:35 0 1 99 0
15:38:36 0 4 25 71
15:38:37 0 0 100
15:38:38 0 11 0 89
15:38:39 0 1 0 99
15:38:40 0 0 100
15:38:41 0 4 32 64
15:38:42 0 0 100 0
15:38:43 0 0 100 0
15:38:44 0 2 48 50
15:38:45 0 0 100
15:38:46 0 12 0 88

Program:

Timer
{
Fun; // time-to-call Function
Interval; // interval
Remain; // remaining time
}
Signal (SIGALARM, TimFun)
Alarm (1)

Timer Tim [MAX];
TimFun ()
{
For (I = 0; I <MAX; I ++)
{
Tim . Remain --;
If (Tim. Remain <= 0)
{
Run (Tim. Fun); // call the function regularly
Tim. Remain = Tim. Interval // Reset
}
Signal (SIGALARM, TimFun );
Alarm (1 );
}


What is the main cause of high resource usage !! (It should not be the Tim function called.. The reason for fun, because after using another method to call all the fun, the endless loop + sleep in fun won't have such a high resource usage)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.