Linux kernel timers How can a module cause a function to be invoked at some future moment in time?

Slides:



Advertisements
Similar presentations
Linux device-driver issues
Advertisements

Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
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.
The Linux PCI Interface An introduction to the PCI configuration space registers.
Timeout for some demos An instructive look at how the Linux Operating System sets up system data-structures.
SiS 315 Graphics Engine Introduction to some capabilities of graphics accelerator hardware.
How to make a pseudo-file As a follow-up to our first lab, we examine the steps needed to create our own ‘/proc’ file.
Kernel timing issues An introduction to the use of kernel timers and work queues.
COMS W6998 Spring 2010 Erich Nahum
Applying kernel timers Could we prevent a device-driver from consuming an excessive amount of processor time?
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
Kernel Event-Timers Our first look at the Linux kernel’s mechanism for managing its dynamic timers.
Kernel timing issues An introduction to the use of kernel timers and work queues.
Kernel timing issues An introduction to the use of kernel timers and work queues By Allan Cruise modified by sdc.
Cs238 Lecture 3 Operating System Structures Dr. Alan R. Davis.
1 Chapter 13 Embedded Systems Embedded Systems Characteristics of Embedded Operating Systems.
Computer System Laboratory
NS Training Hardware. System Controller Module.
Data Types in the Kernel Sarah Diesburg COP 5641.
Lecture 5. AT91 - Memory Map, Timers, and AIC -
Operating System A program that controls the execution of application programs An interface between applications and hardware 1.
1 CzajkowskiMAPLD 2005/139 SEFI Mitigation Technique for COTS Microprocessors – Proton Testing Demonstration D. Czajkowski, P. Samudrala, D. Strobel, and.
Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK = MHz PCLK (for.
Data Types in the Kernel Ted Baker  Andy Wang CIS 4930 / COP 5641.
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.
Sogang University Advanced Operating Systems (Linux Module Programming) Sang Gue Oh, Ph.D.
1 Run-Time Methods for Making Embedded Systems Robust.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 7 OS System Structure.
Ethernet Driver Changes for NET+OS V5.1. Design Changes Resides in bsp\devices\ethernet directory. Source code broken into more C files. Native driver.
Renesas Technology America, Inc. Flash!. CPU Rewrite CPU-rewrite is a term that refers to an Renesas MCU’s ability to erase/program its own internal Flash.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
INTRO TO DEVICE DRIVERS ARP & RARP IMPLEMENTATION B.ANURADHA C.MANOJ KUMAR T.CHITTI BABU BY.
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.
LAB 12: Timer and Interrupt Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
Lab 13 Department of Computer Science and Information Engineering National Taiwan University Lab13 – Interrupt + Timer 2014/12/23 1 /16.
Outline for Today Objectives: –Time and Timers Administrative details: –Talk on learning at 4 in 130 North Building –Questions?
Real-time Systems Lab, Computer Science and Engineering, ASU Quark SPI Interface (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
ENEE150 – 0102 ANDREW GOFFIN Project 4 & Function Pointers.
Real Time Interrupts Section Real-Time Interrupt (RTI) Most operating systems (OS) require an interrupt every T seconds by the RTI RTI interrupts.
MP2: RATE-MONOTONIC CPU SCHEDULING Based on slides by Gourav Khaneja, Raoul Rivas and Keun Yim University of Illinois at Urbana-Champaign Department of.
Chapter 5 - Interrupts.
Microprocessors A practical approach Lesson 2 Hardware description and Delays.
Time Sources and Timing David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Computer Operating Properly Module MTT COMPUTER OPERATING PROPERLY MODULE (COP)
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.
LonWorks Introduction Hwayoung Chae.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
Ch6. Flow of Time Ch7. Getting Hold of Memory 홍원의.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Lecture 7 Interrupt ,Trap and System Call
INSTITUTE: INSTITUTE:PARUL INSTITUTE OF TECHNOLOGY BRANCH : BRANCH :B.E. E.C.5 TH SEM. SUBJECT:MICROCONTROLLER & INTERFACING TOPIC:AVR INTTRUPT TOPIC:AVR.
Timing Measurements 國立中正大學 資訊工程研究所 羅習五 老師 0. Chapter 11 – Timing Measurements kernel notion of time the tick rate: HZ jiffes hardware clocks and timers.
Timers and Time Management Ok-Kyun Ha
Homework Reading Machine Projects Labs
Interrupts and Interrupts Handling
Linux Kernel Development - Robert Love
Interfacing with Hardware
Networked Embedded Systems Sachin Katti
Time Sources and Timing
Anton Burtsev February, 2017
Time Sources and Timing
An introduction to the use of kernel timers and work queues
The Hardware Interface
COMPUTER PERIPHERALS AND INTERFACES
Wireless Embedded Systems
Time Sources and Timing
Presentation transcript:

Linux kernel timers How can a module cause a function to be invoked at some future moment in time?

Hardware timer-counters IA32 systems: several hardware timers External devices, or internal to processor Examples: 8254 Programmable Interval Timer (IRQ0) MC Real Time Clock w/CMOS (IRQ8) Pentium’s 64-bit Time Stamp Counter register Local APIC’s programmable Counter register (optional) 8254 Watchdog Timer (NMI) (optional) Network Interface Card (IRQ varies)

Linux Software Timers Easy for device-driver programmers to use Used mainly for detecting device “lockups” But could also be used for other purposes The driver-writer merely needs to: 1) define a “customized” timeout-function 2) allocate and initialize a kernel-structure 3) call standard routines for timer-control

Software Timer’s Data-Structure struct list_head list; unsigned long expires; unsigned long data; void (*function)( unsigned long ); struct timer_list Use the ‘init_timer()’ routine to initialize the ‘list’ field

Defining your “timeout” action void my_action( unsigned long dataptr ) { /* …perform your desired actions… */ /* then reschedule timer expiration */ next_timeout = jiffies + 5*HZ; mod_timer( &my_timer, next_timeout ); }

Assigning structure’s attributes struct timer_list my_timer; // declared global int init_module( void ) { init_timer( &my_timer );// for ‘list’ setup my_timer.data = (unsigned long)&my_data; my_timer.function = my_action; my_timer.expires = jiffies + 5 * HZ; add_timer( &my_timer ); returnSUCCESS; }

Removing your timer safely void cleanup_module( void ) { int status = del_timer_sync( &my_timer ); // 1 means ‘my_timer’ was queued // 0 means ‘my_timer’ wasn’t queued }

Kernel’s dynamic-timer handling Need to deal efficiently with many timers One big linked list would NOT be efficient Linux adopts a clever partitioning structure Uses special structures (called ‘tvec’s) Timers partitioned by their expiration-times Result: reduces amount of list-processing

Groups of timer lists Array of ‘tvec’ structures (< 0xFF ) ( < 0x3FFF ) ( < 0xFFFFF ) ( < 0x3FFFFFF ) ( < 0xFFFFFFFF )

In-Class Exercise Modify the ‘mytimer.c’ demo (on website) Change expiration-frequency (to 5 secs) Print timer’s messages on user’s console (See our ‘announce.c’ demo for how-to)