Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Timing Subsystem in deep
Rating: 4.6 out of 5(31 ratings)
785 students

Timing Subsystem in deep

Linux Kernel Programming - Timing Subsystem
Created byLinux Trainer
Last updated 4/2021
English
English [Auto],

What you'll learn

  • Programming timing in user space
  • Timing Hardware
  • Jiffies
  • Low resolution & High resolution timers
  • POSIX Clocks

Course content

7 sections98 lectures4h 52m total length
  • date command0:48

    explains how the date command retrieves the current date and time, including the time zone. demonstrates running the command to display the current date, time, and time zone.

  • uptime command5:41

    Explain how the uptime command reports system up time, current users, and 1/5/15 minute load averages, and how to interpret these values relative to CPU cores.

  • Epoch time3:40

    Discover epoch time, or Unix time, as the number of seconds since January 1, 1970, accessible via the time system call. Watch a five-second sleep and a time check.

  • ctime1:27

    Discover how to use ctime to convert a time value into a human-readable string, displaying seconds or other units, via the time library.

  • gettimeofday3:36

    use gettimeofday to capture wall clock time with microsecond resolution via the timeval structure, convert seconds and microseconds to milliseconds, and pass a null timezone pointer since timezone is obsolete.

  • Can gettimeofday() be used for measured elapsed time6:51

    This lecture shows that gettimeofday() cannot reliably measure elapsed time when system clock is changed by NTP. It demonstrates the need for a timer that remains accurate despite clock adjustments.

  • Monotonic clock4:04

    Learn how the monotonic clock measures elapsed time safely, unaffected by system time changes, by reading clock monotonic and comparing it to wall clock time for accurate timing in code.

  • CLOCK_BOOTTIME1:44

    Compare CLOCK_MONOTONIC and CLOCK_BOOTTIME to see how they handle suspend time. MONOTONIC excludes suspend, while CLOCK_BOOTTIME includes it for elapsed time measurements.

  • CLOCK_MONOTONIC_RAW1:36

    Learn how CLOCK_MONOTONIC_RAW avoids time adjustments, unlike CLOCK_MONOTONIC, to measure very short intervals, while CLOCK_MONOTONIC suits longer durations such as minutes, hours, or days.

  • CLOCK_REALTIME2:23

    Explore CLOCK_REALTIME, the real-time clock that provides time of day and system time for stamping and displaying the actual time to users.

  • CLOCK_PROCESS_CPUTIME_ID2:18

    Clock process cputime id measures the CPU time consumed by a process, showing whether your program uses CPU time or waits on I/O; it excludes time waiting for user input.

  • Example to calculate time taken to increment1:22

    Calculate the time a micro CPU takes to increment a variable using clock time, starting and stopping the measurement to capture the elapsed duration and display it.

  • Another Example using clock_gettime1:52

    Compare two methods for dividing by 256—division and a night shift—and time them with clock_gettime to show the night shift is faster due to direct assembly instruction support.

  • CLOCK_MONOTONIC vs CLOCK_PROCESS_CPUTIME_ID1:47

    Compare clock_monotonic and CLOCK_PROCESS_CPUTIME_ID by measuring elapsed time between user input and function calls. Monotonic time advances continuously, while CPU time reflects actual processor usage.

  • CLOCK_THREAD_CPUTIME_ID2:47

    Explore how CLOCK_THREAD_CPUTIME_ID measures CPU time for a thread, compare it with real-time clocks, and interpret timing output that shows per-thread versus wall-clock duration.

  • clock_settime4:34

    Use clock_settime to set the clock and adjust time, with examples of getting current time and adding minutes, and note that monotonic clocks cannot be set for the wall clock.

  • clock_getres0:59

    Demonstrates how clock_getres retrieves the resolution of a specified clock, including alarm clock, monotonic clock, and time clock, revealing nanosecond precision.

  • times3:14

    Learn how the times function reveals user and system time for a process and its children, measure clock ticks per second, and use spend time to illustrate runtime durations.

  • getrusage2:09

    Explore the getrusage interface to measure timing and resource usage for self and child processes, reporting seconds and microseconds with various clocks in user space.

Requirements

  • Should have a basic understanding of Linux Kernel modules
  • C Language

Description

Timing Measurements in Linux Kernel

Many computer activities are based on timing measurements.

E.g. Your Computer display is turned off, if you have not pressed a key or moved your mouse for a particular time.

Linux timing subsystem mainly handles two types of timing activities

        1. Keeping the current time and date

                a. time() , gettimeofday() and clock_gettime()

                b. Time stamps for files and network packets

        2. Maintaining Timers

                a. Mechanisms to notify kernel and user space (ex. alarm()) that a certain interval of time has elapsed.

Hardware Devices

Linux depends on hardware devices to maintain time. These devices can be basically classified into two types:

        1. Clocks/Counters:  provide precise time measurements

                Used to keep track of current time of day

        2. Timers: Issue interrupts at fixed, predefined frequency.

                Used for implementing software timers

What will you learn from this course?

  • Various timing commands: date, uptime

  • POSIX Clocks: CLOCK_BOOTTIME, CLOCK_MONOTONIC_RAW, CLOCK_REALTIME, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID

  • Timing System calls: ctime, gettimeofday, clock_gettime, clock_settime, clock_getres, times, getrusage

  • Setting time from userspace

  • How to measure time for a particular instruction

  • Hardware Devices used in timing measurement: RTC, TSC, Programmable Interval Timer, APIC, High Precision Event Timer

  • Jiffies

  • Low Resolution and High Resolution Timers

This course comes with a 30 day money back guaranteed!. If you are not satisfied with the course, you'll get your money back

So what are you waiting for, enroll now and take the next step in learning Timing subsystem in Linux Kernel

Who this course is for:

  • Linux Kernel Developers interested in gaining deep knowledge about timing subsystem