Round_jiffies and apiround_jiffies on the kernel scheduled mechanism API

Source: Internet
Author: User

Round_jiffies and apiround_jiffies on the kernel scheduled mechanism API

Round_jiffies on the kernel timing mechanism API

Unsigned long _ round_jiffies (unsigned long j, int cpu) The user converts jiffies to an integer multiple of HZ, that is, the whole second. source code analysis: unsigned long _ round_jiffies (unsigned long j, int cpu) {return round_jiffies_common (j, cpu, false);} static unsigned long round_jiffies_common (unsigned long j, int cpu, bool force_up) {int rem; unsigned long original = j; j + = cpu * 3; rem = j % HZ; # force_up here is false, therefore, the rem <HZ/4 is decomposed here to determine whether it is round_down or round_upif (rem < HZ/4 &&! Force_up)/* round down */j = j-rem; else/* round up */j = j-rem + HZ;/* now that we have rounded, subtract the extra skew again */j-= cpu * 3;/** Make sure j is still in the future. otherwise return the * unmodified value. */# Check whether the current jiffies is faster than the parameter j. Generally, it should not. Therefore, the jreturn time_is_after_jiffies (j) after round is returned here )? J: original;} the larger the number of CPUs, the larger the value returned by this function.

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.