Lab 13 Department of Computer Science and Information Engineering National Taiwan University Lab13 – Interrupt + Timer 2014/12/23 1 /16.

Slides:



Advertisements
Similar presentations
1 Exceptions, Interrupts & Traps Operating System Hebrew University Spring 2007.
Advertisements

Tutorial 3 - Linux Interrupt Handling -
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
OS Spring’04 Introduction Operating Systems Spring 2004.
Exceptions, Interrupts & Traps
Computer System Laboratory
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
DAT2343 Accessing Services Through Interrupts © Alan T. Pinck / Algonquin College; 2003.
MICROPROCESSOR INPUT/OUTPUT
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Lab 10 Department of Computer Science and Information Engineering National Taiwan University Lab10 – Debugging II 2014/12/2 1 /16.
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Microprocessors 1 MCS-51 Interrupts.
Time Management.  Time management is concerned with OS facilities and services which measure real time, and is essential to the operation of timesharing.
Implementation of Embedded OS Lab3 Linux Kernel Modules.
Lab 14 Department of Computer Science and Information Engineering National Taiwan University Lab14 – Camera 2014/12/30 1 /14.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Implementation of Embedded OS Lab3 Porting μC/OS-II.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Interrupt-Driven I/O There are different types of interrupts –Hardware Generated by the 8259 PIC – signals the CPU to suspend execution of the current.
BIOS and DOS Interrupts Basic Input /Outpu System Disk Operating System.
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.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Lecture 7 Interrupt ,Trap and System Call
Computer System Structures Interrupts
Introduction to Operating Systems
Linux Kernel Development - Robert Love
Interrupts and exceptions
Interrupts and signals
Exceptional Control Flow
Microprocessor Systems Design I
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
Timer and Interrupts.
Exceptional Control Flow
Anton Burtsev February, 2017
Protection of System Resources
Exceptional Control Flow
Computer System Laboratory
Computer System Overview
Processor Fundamentals
Architectural Support for OS
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
Computer System Laboratory
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
COMP3221: Microprocessors and Embedded Systems
Chapter 13: I/O Systems.
Interrupts and System Calls
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Lab 13 Department of Computer Science and Information Engineering National Taiwan University Lab13 – Interrupt + Timer 2014/12/23 1 /16

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  Understand the Linux interrupt handling, the hardware timer and Linux timer, and also learn how to control 8-bit LED lamps, 4-Digits 7 segment LED and keypad. 2014/12/23/16 2

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  Host System  Windows XP  Build System  VirtualBox + Ubuntu 8.04  Target System  Creator XScale PXA270  Software  Creator PXA270 LCD driver, please refer to Lab12  You can download all software from RSWiki CSL Course Software.RSWiki CSL Course Software 2014/12/23/16 3

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  An interrupt is a signal to the processor.  The processor responds by suspending its current activities, saving its state, and executing a small program called an interrupt handler (interrupt service routine, ISR) to deal with the event.  The act of initiating a hardware interrupt is referred to as an interrupt request (IRQ).  Interrupts are a commonly used technique for computer multitasking. 2014/12/23/16 4 Reference: wiki info: interrupt,

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  Asynchronous interrupt: caused by an external event.  Maskable interrupt (IRQ)  E.g., I/O request  Non-maskable interrupt  E.g., watchdog timer  Synchronous interrupt (Exception)  Faults  E.g., page fault  Traps  E.g., divide by zero  Aborts  E.g., machine check  Software interrupt  E.g., system call 2014/12/23/16 5 Reference: Daniel P. Bovert & Marco Cesati, “Understanding the Linux Kernel 3 rd ”, chapter 4, O’Reilly

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  Systems often use a programmable interrupt controller (PIC) to group the device interrupts together before passing on the signal to a single interrupt pin on the CPU. 2014/12/23/16 6 Reference: David Rusling, “The Linux Kernel”, chapter 7, New Riders Pub

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  Linux uses a table ( irq_action ) of pointers to data structures ( irqaction ) containing the addresses of the interrupt service routine (ISR).  When interrupt happens, the kernel will execute the corresponding ISR to handle it. 2014/12/23/16 7 Reference: David Rusling, “The Linux Kernel”, chapter 7, New Riders Pub

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  In Linux, there is a related API, request_irq(), to register an interrupt handler, so developers can set their own handler with a specific IRQ. int request_irq( unsigned int irq, void (*handler) (int, void *, struct pt_regs *), unsigned long irqflags, const char *devname, void *dev_id );  In the Creator PXA270 LCD driver, you can find this API which registers a timer interrupt. 2014/12/23/16 8

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  Computer systems usually have at least one timer. These are typically digital counters that decrement at a fixed frequency, which are often configurable and interrupt the processor when reaching zero.  As the number of hardware timers in a computer system or processor is finite, OSes often use a single hardware timer to implement an extensible set of software timers.  Some timer devices count up instead of down and have a register whose value is compared with the counter to determine when to interrupt and restart the count at zero. 2014/12/23/16 9 Reference: wiki info: timer,

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  The oscillator provides a fixed input frequency to the timer device, and the counter counts down one unit for each cycle of the oscillator.  When it reaches zero, it generates an interrupt signal.  There might also be a counter input register whose value is loaded into the counter when it reaches zero. 2014/12/23/16 10 Reference: VMWare, “Timekeeping in VMware Virtual Machines”,

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  PXA270 provides a set of timers that allows software to generate timer interrupts.  The related registers on PXA270 are as follows:  OS Timer Count Registers ( OSCRx ): counter  Count up one unit for each cycle of the oscillator.  OS Timer Match Registers ( OSMRx ): counter input  When OSCR reaches the value of OSMR, it will generate an interrupt.  OS Match Control Registers ( OMCRx ): control OS timers  Set the frequency of oscillator, set periodic timer, automatically reset OSCRx after it reaches the value of OSMRx, etc.  For more information about these registers, please refer to Intel PXA27x Processor Family Developer’s Manual, Chapter 22.Intel PXA27x Processor Family Developer’s Manual 2014/12/23/16 11

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  Interrupt handlers need to finish up quickly and do not keep interrupts blocked for long.  Therefore, Linux splits an interrupt handler into two halves.  Top-half  Perform time critical tasks, and schedule its bottom half.  Bottom-half  Awake waiting processes, and start up another I/O operation and so on. 2014/12/23/16 12 Reference: Jonathan Corbet et al., “Linux Device Drivers 3 rd ”, chapter 10, O’Reilly

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  You can see /include/linux/jiffies.h which defines the timer interrupt frequency.  #define ACTHZ  And see /kernel/timer.c which defines both top-half and bottom-half of interrupt handlers.  Top-half: do_timer(…)  Bottom-half: run_timer_softirq(…) 2014/12/23/16 13

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  Trace the driver’s code for 8-bit LED lamps, 4-Digits 7 segment LED and keypad, and see how they work.  Modify the driver codes such that the 8-bit LED lamps can sparkle in your own pattern.  Hints  See creator_pxa270_lcdtxt_ioctl for these operations.  See _7segment_timer_irq which is the timer interrupt handler.  Trace ScanTimer in the driver to know how the keypad works.  For more information about hardware registers, please refer to Create Creator PreSOCes Development Kit User’s Guide, 3.7.2, and /12/23/16 14

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  Implement a stopwatch.  The resolution should be in 0.1 second and 0.01 second which can be switched by the keypad.  The value of the counter should be displayed on the 4-digit 7-segment LED in decimal form.  It can be started, suspended, resumed, and reset by pressing the buttons of the keypad.  Define these actions of the keypad by yourselves. 2014/12/23/16 15

Lab 13 Department of Computer Science and Information Engineering National Taiwan University  Show your sparkling 8-bit LED lamps in PXA270.  Show your stopwatch.  Display the time in 4-Digits 7 segment LED.  Control the stopwatch by the keypad in PXA /12/23/16 16