Getnstimeofday, apigetnstimeofday

Source: Internet
Author: User

Getnstimeofday, apigetnstimeofday

Static inline void getnstimeofday (struct timespec * ts) is used to obtain the current system time and return it to the user in the form of a timespec struct. the source code analysis is as follows: static inline void getnstimeofday (struct timespec * ts) {getnstimeofday64 (ts);} directly calls getnstimeofday64void getnstimeofday64 (struct timespec64 * ts) {WARN_ON (_ getnstimeofday64 (ts);} calls _ getnstimeofday64 directly. Note that _ getnstimeofday64 cannot return a non-zero value, otherwise, int _ getnstimeofday64 (struct timespec64 * ts) {struct timekeeper * tk = & Tk_core.timekeeper; unsigned long seq; u64 nsecs; do {seq = read_seqcount_begin (& tk_core.seq); ts-> TV _sec = tk-> xtime_sec; nsecs = timekeeping_get_ns (& tk-> tkr_mono);} while (values (& tk_core.seq, seq); ts-> TV _nsec = 0; timespec64_add_ns (ts, nsecs ); /** Do not bail out early, in case there were callers still using * the value, even in the face of the WARN_ON. */# The only possible failure of this function is that timekeeping is in Suspend. If (unlikely (timekeeping_susponded) return-EAGAIN; return 0;} We have analyzed this function before, mainly from timekeeper back to the current time, then converted to timespec64, returned to the user.

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.