Time Sources and Timing David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO 63143 1.

Slides:



Advertisements
Similar presentations
Real-Time Library: RTX
Advertisements

Operating Systems Process Scheduling (Ch 3.2, )
CS 6560 Operating System Design Lecture 7: Kernel Synchronization Kernel Time Management.
The Process Control Block From: A Process Control Block (PCB, also called Task Control Block or Task Struct) is.
BFS: Brain F*ck Scheduler Jacob Chan. Objectives  Brain F*ck Scheduling  What it is  How it works  Features  Scalability  Limitations  Definition.
Effects of Clock Resolution on the Scheduling of Interactive and Soft Real- Time Processes by Yoav Etsion, Dan Tsafrir, Dror G. Feitelson Presented by.
1 Soft Timers: Efficient Microsecond Software Timer Support For Network Processing Mohit Aron and Peter Druschel Rice University Presented By Jonathan.
Introduction to Operating Systems What is an operating system? Examples How do many programs run at the same time, with one processor?
COMS W6998 Spring 2010 Erich Nahum
Soft Timers: Efficient Microsecond Software Timer Support For Network Processing Mohit Aron and Peter Druschel Rice University Presented by Reinette Grobler.
Chapter 13 Embedded Systems
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Operating system Structure and Operation
Process Description and Control A process is sometimes called a task, it is a program in execution.
1 Chapter 13 Embedded Systems Embedded Systems Characteristics of Embedded Operating Systems.
Operating System Process Scheduling (Ch 4.2, )
Virtual Memory.
4061 Session 17 (3/19). Today Time in UNIX Today’s Objectives Define what is meant when a system is called “interrupt-driven” Describe some trade-offs.
Real-Time Concepts for Embedded Systems
CS591 (Spring 2001) The Linux Kernel: Debugging. CS591 (Spring 2001) Accessing the “Black Box” n Kernel code: n Not always executed in context of a process.
Chapter 3 Process Description and Control
Real-Time Systems Design1 Priority Inversion When a low-priority task blocks a higher-priority one, a priority inversion is said to occur Assume that priorities:
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
Time Management.  Time management is concerned with OS facilities and services which measure real time, and is essential to the operation of timesharing.
Outline for Today Objectives: –Time and Timers Administrative details: –Talk on learning at 4 in 130 North Building –Questions?
1 Soft Timers: Efficient Microsecond Software Timer Support For Network Processing Mohit Aron and Peter Druschel Rice University Presented By Oindrila.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Timers and Clocks II.
4P13 Week 2 & 3 Talking Points 1. Kernel Processes 2.
Computer Organization Instruction Set Architecture (ISA) Instruction Set Architecture (ISA), or simply Architecture, of a computer is the.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
How & When The Kernel Runs David Ferry, Chris Gill Department of Computer Science and Engineering Washington University, St. Louis MO
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Linux Boot Process on the Raspberry Pi 2 1 David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis,
Scheduling Classes and Real-Time Scheduling in Linux David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St.
Interrupts and Interrupt Handling David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
Ch6. Flow of Time Ch7. Getting Hold of Memory 홍원의.
Kernel Tracing David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Processes David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Real-Time Operating Systems RTOS For Embedded systems.
Timers and Time Management Ok-Kyun Ha
Outline for Today Objectives: –Time and Timers Administrative details: –About the final…
Kernel Synchronization David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Computer System Structures
Scheduling of Non-Real-Time Tasks in Linux (SCHED_NORMAL/SCHED_OTHER)
Process Management Process Concept Why only the global variables?
How & When The Kernel Runs
Midterm Review Chris Gill CSE 422S - Operating Systems Organization
Time Sources and Timing
Midterm Review David Ferry, Chris Gill
Processes David Ferry, Chris Gill
Time Sources and Timing
Semester Review Chris Gill CSE 422S - Operating Systems Organization
Modularity and Memory Clearly, programs must have access to memory
Interrupts and Interrupt Handling
Lecture Topics: 11/1 General Operating System Concepts Processes
Top Half / Bottom Half Processing
Overview of the Lab 2 Assignment: Multicore Real-Time Tasks
Midterm Review Brian Kocoloski
How & When The Kernel Runs
Scheduling of Regular Tasks in Linux
Time Sources and Timing
Processes David Ferry CSCI 3500 – Operating Systems
Kernel Tracing David Ferry, Chris Gill, Brian Kocoloski
Scheduling Classes and Real-Time Scheduling in Linux
Interrupts and Interrupt Handling
Processes David Ferry, Chris Gill, Brian Kocoloski
COMP755 Advanced Operating Systems
Scheduling of Regular Tasks in Linux
Presentation transcript:

Time Sources and Timing David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO

Questions From Last Time Q: Why does the kernel create an init thread at boot instead of using the original execution context? – Robert A: The start_kernel execution context in main.c eventually becomes the main processor idle loop, a.k.a. the swapper or sched process. (Follow the start_kernel function through to cpu_idle_loop() ) CSE 522S – Advanced Operating Systems2

Questions From Last Time Q: Do we really need to issue make clean when rebuilding the kernel? – John A: Not always, but probably… CSE 522S – Advanced Operating Systems3 foo.c unistd.h #define NR_SYSCALLS 388 unistd.h #define NR_SYSCALLS 388 foo.o NR_SYSCALLS = 388 foo.o NR_SYSCALLS = 388

Questions From Last Time Q: Do we really need to issue make clean when rebuilding the kernel? – John A: Not always, but probably… CSE 522S – Advanced Operating Systems4 foo.c bar.c unistd.h #define NR_SYSCALLS 292 unistd.h #define NR_SYSCALLS 292 foo.o NR_SYSCALLS = 388 foo.o NR_SYSCALLS = 388 bar.o NR_SYSCALLS = 292 bar.o NR_SYSCALLS = 292

What is meant by Time? Absolute time since some past event, E.g.: – Seconds since Unix Epoch – Seconds since system boot Relative time, E.g.: – Seconds between two events – Ten seconds into the future – Execution time of a program segment World time, E.g.: – February 4 th, 10:37 AM An OS must approximate time to provide time-based functions for users. CSE 522S – Advanced Operating Systems5

Time Sources RTC (Real-Time Clock) – Available on most computers (not on RPI 2) – Low precision (as low as 0.5 seconds) Hardware Timers – Might be used to generate interrupts, might be queryable – Run at a variety of frequencies – Programmable Interval Timer (PIT) – High-Performance Event Timer (HPET) – Programmable Interrupt Controller (PIC) – Advanced Programmable Interrupt Controller (APIC) Processor Cycles – Timestamp Counter (TSC) on x86, 64-bit – Cycle Counter (CCNT) on ARM, 32-bit, 64-cycle divider, not accessible in user mode – Potentially very high accuracy – Can generate interrupts on x86 with TSC-deadline CSE 522S – Advanced Operating Systems6

How does the kernel schedule services? Three approaches: 1.Timer interrupts to regularly provide service e.g.: task scheduling, current time update 2.Kernel timers ( hrtimers, legacy timers) 3.Kernel threads (not time dependent) A portable OS must use whatever timer hardware is available to support actions #1 and #2. CSE 522S – Advanced Operating Systems7

Basic Timer Interrupt in Linux Historically the OS would run periodically: – Fundamental timestep is variable HZ found in /include/asm-generic/param.h – OS function tick_periodic() runs each 1/HZ seconds – jiffies variable tracks number of ticks since boot – xtime variable tracks wall-clock time – Current time since boot: jiffies * 1/HZ – Current wall time: boot_time + jiffies * 1/HZ – Timers are checked for expiry each tick As a modern approach: – Excessive power consumption (can’t really idle processors) – Inappropriate for highly virtualized systems – Might be appropriate for real-time systems CSE 522S – Advanced Operating Systems8

Modern Timer Interrupt in Linux Two fundamental operation modes: – Periodic ( CLOCK_EVT_MODE_PERIODIC ) – One-shot ( CLOCK_EVT_MODE_ONESHOT ) One-shot mode ( CONFIG_NO_HZ ): – All timer events are independent (not periodic) – Next timer event is scheduled for: Next hrtimer expiration Next 1/HZ interval, whichever is sooner Not rescheduled if no runnable tasks – jiffies is maintained as though periodic – Big power savings in idle CSE 522S – Advanced Operating Systems9

Problems with legacy time system Legacy timers could only expire each tick – Latency problems: with 10ms tick a timeout might be delivered 9.9ms late – Resolution problems: with a 10ms tick all we know was that timeout was 0-9.9ms ago Legacy timer wheel implementation problems: – Bad worst case expiration running time (O(N)) – 95-99% of timers never actually expire (e.g. http timeouts, error checking) but still incur overhead – Thus, not optimized for “millions of network timers” case CSE 522S – Advanced Operating Systems10

hrtimers subsystem The kernel now provides a high resolution timing subsystem: hrtimers – Not bound to jiffies – Can use multiple time sources – High resolution (nanosecond representation) Implementation: – Per-CPU timer list stored as a sorted red-black tree for fast expiration – Separate list for fast removal (no tree walking) – Expiration handled by dedicated interrupts CSE 522S – Advanced Operating Systems11