Διακοπές (Interrupts) K.Harteros G.Kornaros

Σχετικά έγγραφα
Ενσωµατωµένα Υπολογιστικά Συστήµατα (Embedded Computer Systems)

Περίγραμμα. Μορφή εντολής SWI. Διακοπές Λογισμικού - SoftWare Interrupts (SWIs) Τι είναι τα SWI? Εξαιρέσεις και Διακοπές.

Instruction Execution Times

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

Προηγμένοι Μικροεπεξεργαστές. Φροντιστήριο 4 Real Mode Interrupts

Αρχιτεκτονική του ARM. K.Harteros G.Kornaros

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

ΔΙΑΧΥΤΑ ΚΑΙ ΕΝΣΩΜΑΤΩΜΕΝΑ ΣΥΣΤΗΜΑΤΑ

Συστήματα Διαχείρισης Βάσεων Δεδομένων

(C) 2010 Pearson Education, Inc. All rights reserved.

Assalamu `alaikum wr. wb.

Modbus basic setup notes for IO-Link AL1xxx Master Block

The challenges of non-stable predicates

Finite Field Problems: Solutions

Τέτοιες λειτουργίες γίνονται διαμέσου του

ΗΜΥ 213 Εργαστήριο Οργάνωσης Υπολογιστών και Μικροεπεξεργαστών

ΗΜΥ 213. Εργαστήριο Οργάνωσης Η.Y. και Μικροεπεξεργαστών week 5. Διδάσκων: Δρ. Γιώργος Ζάγγουλος

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής Device software installation and software upgrade

Block Ciphers Modes. Ramki Thurimella

EE512: Error Control Coding

Section 8.3 Trigonometric Equations

Approximation of distance between locations on earth given by latitude and longitude

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Capacitors - Capacitance, Charge and Potential Difference

Περιγραφή και Έλεγχος ιεργασιών

CYTA Cloud Server Set Up Instructions

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά.

Δίκτυα Δακτυλίου. Token Ring - Polling

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

VBA ΣΤΟ WORD. 1. Συχνά, όταν ήθελα να δώσω ένα φυλλάδιο εργασίας με ασκήσεις στους μαθητές έκανα το εξής: Version ΗΜΙΤΕΛΗΣ!!!!

TMA4115 Matematikk 3

Δημιουργία Λογαριασμού Διαχείρισης Business Telephony Create a Management Account for Business Telephony

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

[1] P Q. Fig. 3.1

Right Rear Door. Let's now finish the door hinge saga with the right rear door

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

ΕΠΛ221: Οργάνωση Υπολογιστών και Συμβολικός Προγραμματισμός. Εργαστήριο Αρ. 2

Μηχανοτρονική. Τμήμα Μηχανικών Παραγωγής και Διοίκησης 7 ο Εξάμηνο,

The Simply Typed Lambda Calculus

ΤΕΧΝΙΚΕΣ ΑΥΞΗΣΗΣ ΤΗΣ ΑΠΟΔΟΣΗΣ ΤΩΝ ΥΠΟΛΟΓΙΣΤΩΝ I

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

ΗΜΥ Εργαστήριο Οργάνωσης Υπολογιστών και Μικροεπεξεργαστών

C.S. 430 Assignment 6, Sample Solutions

Section 9.2 Polar Equations and Graphs

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr

Numerical Analysis FMN011

Προγραμματισμός Ταυτόχρονος Προγραμματισμός

Advanced Subsidiary Unit 1: Understanding and Written Response

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Galatia SIL Keyboard Information

b. Use the parametrization from (a) to compute the area of S a as S a ds. Be sure to substitute for ds!

the total number of electrons passing through the lamp.

(1) Describe the process by which mercury atoms become excited in a fluorescent tube (3)

ΑΝΙΧΝΕΥΣΗ ΓΕΓΟΝΟΤΩΝ ΒΗΜΑΤΙΣΜΟΥ ΜΕ ΧΡΗΣΗ ΕΠΙΤΑΧΥΝΣΙΟΜΕΤΡΩΝ ΔΙΠΛΩΜΑΤΙΚΗ ΕΡΓΑΣΙΑ

Potential Dividers. 46 minutes. 46 marks. Page 1 of 11

derivation of the Laplacian from rectangular to spherical coordinates

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

Calculating the propagation delay of coaxial cable

PARTIAL NOTES for 6.1 Trigonometric Identities

Fractional Colorings and Zykov Products of graphs

SOAP API. Table of Contents

Προσομοίωση BP με το Bizagi Modeler

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 5: Component Adaptation Environment (COPE)

PortSip Softphone. Ελληνικά Ι English 1/20

ΕΘΝΙΚΟ ΜΕΤΣΟΒΙΟ ΠΟΛΥΤΕΧΝΕΙΟ ΣΧΟΛΗ ΠΟΛΙΤΙΚΩΝ ΜΗΧΑΝΙΚΩΝ. «Θεσμικό Πλαίσιο Φωτοβολταïκών Συστημάτων- Βέλτιστη Απόδοση Μέσω Τρόπων Στήριξης»

Math 6 SL Probability Distributions Practice Test Mark Scheme

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι

SPEEDO AQUABEAT. Specially Designed for Aquatic Athletes and Active People

«ΨΥΧΙΚΗ ΥΓΕΙΑ ΚΑΙ ΣΕΞΟΥΑΛΙΚΗ» ΠΑΝΕΥΡΩΠΑΪΚΗ ΕΡΕΥΝΑ ΤΗΣ GAMIAN- EUROPE

Πώς μπορεί κανείς να έχει έναν διερμηνέα κατά την επίσκεψή του στον Οικογενειακό του Γιατρό στο Ίσλινγκτον Getting an interpreter when you visit your

Οδηγίες χρήσης. Registered. Οδηγίες ένταξης σήματος D-U-N-S Registered στην ιστοσελίδα σας και χρήσης του στην ηλεκτρονική σας επικοινωνία

Partial Differential Equations in Biology The boundary element method. March 26, 2013

12. Διακοπές Interrupts (IRQ)

Writing kernels for fun and profit

Test Data Management in Practice

Εργαστήριο 9. Styling with Javascript

Υλοποίηση Δικτυακών Υποδομών και Υπηρεσιών: OSPF Cost

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

CMOS Technology for Computer Architects

ΠΛΕ- 027 Μικροεπεξεργαστές 7ο μάθημα: Αρχιτεκτονική πυρήνα: Πρόβλεψη διακλάδωσης, Εξαιρέσεις

2 Composition. Invertible Mappings

Ενότητα 2 Εργαλεία για την αναζήτηση εργασίας: Το Βιογραφικό Σημείωμα

ΤΕΧΝΟΛΟΓΙΚΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ ΤΜΗΜΑ ΝΟΣΗΛΕΥΤΙΚΗΣ

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ - ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΠΛ 133: ΑΝΤΙΚΕΙΜΕΝΟΣΤΡΕΦΗΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΕΡΓΑΣΤΗΡΙΟ 3 Javadoc Tutorial

Μηχανική Μάθηση Hypothesis Testing

Οδηγίες χρήσης υλικού D U N S Registered

Ρηματική άποψη. (Aspect of the verb) Α. Θέματα και άποψη του ρήματος (Verb stems and aspect)

Section 7.6 Double and Half Angle Formulas

Example Sheet 3 Solutions

The municipality of Apokoronas has created a new app for your smart phone.

Κατανοώντας και στηρίζοντας τα παιδιά που πενθούν στο σχολικό πλαίσιο

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

Κεφάλαιο 1ο Πολυπρογραμματισμός Πολυδιεργασία Κατηγορίες Λειτουργικών Συστημάτων

Εικονική Μνήμη (virtual memory)

Transcript:

Διακοπές (Interrupts) K.Harteros G.Kornaros

Περίγραμμα Interrupts Διαφορετικά είδη interrupts στον επεξεργαστή ARM Καθυστέρηση των Interrupt Interrupt handlers Διαφορετικά είδη interrupt handlers Θέματα συγχρονισμού με τους interrupt handlers 2

Events Two types of events Planned (key pressed, timer periodical interrupt, software interrupt) called Interrupts Unplanned (data abort, (undefined) instruction abort ), called exceptions Manage events the normal flow of execution from one instruction to the next is halted and re-directed to another instruction that is designed specificallyto handle that event Once the event has been serviced the processor can resume normal execution by setting the program counter to point to the instruction after the instruction that was halted IRQ goes high o synchronous with clock o Asychronous with clock 3

Ιnterrupts στον επεξεργαστή ARM Πολλά είδη exceptions (interrupts) SWIs: Reserved για κλήση ρουτινών του Λειτουργικού Συστήματος (supervisor mode) IRQ/FIQ: προερχόμενα από ένα εξωτερικό περιφερειακό που απαιτεί προσοχή - εξυπηρέτηση IRQ (Interrupt Request) General-purpose interrupts Παράδειγμα: periodic timer interrupt to force a context switch FIQ (Fast Interrupt Request) Reserved για μια πηγή interrupt που απαιτεί γρήγορο χρόνο απόκρισης Παράδειγμα : direct memory access to move blocks of memory Σύγκριση των δύο: Τα IRQs έχουν μικρότερη προτεραιότητα από τα FIQs Τα IRQs έχουν μεγαλύτερη καθυστέρηση διακοπής από τα FIQs 4

Program Status Registers (CPSR & SPSR) Interrupt Disable bits I = 1, disables the IRQ F = 1, disables the FIQ Mode bits: processor mode 5

Προτεραιότητες εξαιρέσεων 6

Χειρισμός IRQ και FIQ Όταν συμβαίνει ένα IRQ τότε ο επεξεργαστής: Copies CPSR into SPSR_irq Sets appropriate CPSR bits Sets mode field bits to 10010 Disable further IRQs Maps in appropriate banked registers Stores the return address in LR_irq Sets PC to vector address 0x00000018 IRQ handling To return, exception handler needs to: Restore CPSR from SPSR_irq Restore PC from LR_irq Return to user mode Όταν συμβαίνει ένα FIQ τότε ο επεξεργαστής: Copies CPSR into SPSR_fiq Sets appropriate CPSR bits Sets mode field bits to 10001 Disable further IRQs and FIQs Maps in appropriate banked registers FIQ handling Stores the return address in LR_fiq Sets PC to vector address 0x0000001c To return, exception handler needs to: Restore CPSR from SPSR_fiq Restore PC from LR_fiq Return to user mode 7

Interrupt Handlers Όταν συμβεί ένα interrupt, ο επεξεργαστής θα εξυπηρετήσει το interrupt εκτελώντας έναν interrupt handler (επίσης ονομάζεται ρουτίνα εξυπηρέτησης interrupt (ISR)) 8

Καθυστέρηση των Διακοπών Καθυστέρηση διακοπής Το χρονικό διάστημα από τη στιγμή που ένα εξωτερικό σήμα ζητάει interruptrequest έως το πρώτο fetch μιας εντολής ενός συγκεκριμένου ISR Επηρεάζεται από τον αριθμό των ταυτόχρονων πηγών interrupt που πρέπει να χειριστεί. Παράγοντες που επηρεάζουν την καθυστέρηση ενός interrupt: Time taken to recognize the interrupt Time taken by the CPU to complete its current instruction (depends on whether the CPU is executing a multi-cycle or a single-cycle instruction) Time taken by the CPU to perform a context switch (switching in banked registers, saving program counter, etc.) Time taken to fetch the interrupt vector Time taken to start the interrupt service routine executing 9

FIQs Within IRQ Servicing Interrupts μπορούν να συμβούν ενδιάμεσα στα interrupt handlers 10

Θέματα χρονισμού στα Interrupts Προτού μία ISR κάνει οτιδήποτε, πρέπει να αποθηκεύσει τους καταχωρητές του τρέχοντος προγράμματος (if the ISR overwrites those registers) Γι αυτό το λόγο το FIQ έχουν πολλούς extra registers για να ελαχιστοποιηθεί το overhead να αποθηκευτεί το περιβάλλον του CPU 11

Γιατί είναι πιο γρήγορα τα FIQs Τα FIQs είναι ταχύτερα από τα IRQs όσον αφορά την καθυστέρηση του interrupt FIQ mode has five extra registers at its disposal No need to save registers r8 r12 These registers are banked in FIQ mode Convenient to store status between calls to the handler FIQ vector is the last entry in the vector table The FIQ handler can be placed directly at the vector location and run sequentially starting from that location Cache-based systems: Vector table + FIQ handler all locked down into one block 12

Διακοπές και Στοίβα Τα Stacks είναι σημαντικά στην διαχείριση των interrupt Especially in handling nested interrupts Who sets up the IRQ and FIQ stacks and when? Το μέγεθος του Stack εξαρτάται από τον τύπο του ISR Nested ISR requires more memory space Stack grows in size with the number of nested interrupts Η καλή σχεδίαση του stack design πρέπει να αποφύγει την υπερχείλιση του stack (where stack extends beyond its allocated memory) δύο μέθοδοι: Memory protection Call stack-check function at the start of each routine Είναι σημαντικό στα ενσωματωμένα συστήματα να γωρίζουμε το μέγεθος του stack πριν την εκτέλεση (ως μέρος της σχεδίασης της εφαρμογής) 13

Διακοπές και Στοίβα 14

Ελαχιστοποίηση της καθυστέρησης Διακοπών Nested interrupt handler (problem with stack grow) Allows further interrupts to occur when a current interrupt is being serviced Re-enable interrupts at a safe point in the current ISR Ultimately, nested interrupts roll back to the original ISR Προτεραιότητες στις Διακοπές Ignore interrupts of the same/lower priority than the current interrupt Higher-priority tasks can interrupt the current ISR Higher-priority interrupts have a lower average interrupt latency 15

Τύποι χειριστών διακοπών Μη εμφωλευμένος χειριστής interrupt (simplest possible) Services individual interrupts sequentially, one interrupt at a time εμφωλευμένος χειριστής interrupt Handles multiple interrupts without priority assignment Re-entrant (prioritized) interrupt handler Handles multiple interrupts that can be prioritized 16

Μη εμφωλευμένος χειριστής interrupt Does not handle any further interrupts until the current interrupt is serviced and control returns to the interrupted task Not suitable for embedded systems where interrupts have varying priorities and where interrupt latency matters However, relatively easy to implement and debug Inside the ISR (after the processor has disabled interrupts, copied cpsr into spsr_mode, set the etc.) Save context subset of the current processor mode s nonbanked registers Not necessary to save the spsr_mode why? ISR identifies the external interrupt source how? Service the interrupt source and reset the interrupt Restore context Restore cpsr and pc 17

Εμφωλευμένος χειριστής interrupt Επιτρέπει σε κάποιο άλλο interrupt να συμβεί μέσα στο τρέχον handler που εκτελείται By re-enabling interrupts at a safe point before ISR finishes servicing the current interrupt Προσοχή πρέπει να δοθεί στην υλοποίηση Protect context saving/restoration from interruption Check stack and protect against register corruption Increases code complexity, but improves interrupt latency Δεν υπάρχει διαφορά-διάκριση μεταξύ interrupts υψηλής και χαμηλής προτεραιότητας Time taken to service an interrupt can be high for highpriority interrupts 18

Re-entrant (Prioritized) Interrupt Handler Allows for higher-priority interrupts to occur within the currently executing handler By re-enabling higher-priority interrupts within the handler By disabling all interrupts of lower priority within the handler Same care needs to be taken in the implementation Protect context saving/restoration from interruption, check stack overflow Does distinguish between high and low priority interrupts Interrupt latency can be better for high-priority interrupts 19

Re-enabling Interrupts in an ISR What problems can you anticipate if you re-enable interrupts in an ISR? When you save context and interrupts have already been re-enabled, this can be a problem, why? Re-enable interrupts only after saving context When you restore context and interrupts have been reenabled, this can be a problem Mask interrupts when you are restoring context If you haven t cleared the current interrupt source before re-enabling interrupts in a nested or re-entrant ISR, this can be a problem You can get an infinite sequence of interrupts (or a race condition) make sure to clear the current source before re-enabling interrupts Stack overflow issues 20

False/Ghost Interrupts When the interrupt handler executes the return to the interrupted instruction before clearing the original interrupt source Noise on the interrupt-assertion lines 21

Writing your Own ISR You can write your own ISR completely in C Use the irq function declaration keyword Preserves all registers used by the ISR on the stack o Preserves the lr but only if another function is called from the ISR Exits the function cleanly (sets PC and CPSR correctly on exit) Cannot be used for re-entrant interrupt handlers, Why? What are the implications of this on nested interrupt handlers? 22

Διαμοιρασμός Πόρων Across Interrupts Need to control resource sharing across interrupts Interrupts can occur asynchronously (i.e., whenever they want) Access to shared resources and global variables must be handled in a way that does not corrupt the program Normally done by masking interrupts before accessing shared data and unmasking interrupts afterwards Clearly, when interrupt-masking occurs, interrupt latency will be higher Start with a simple keyboard ISR and then understand what happens when it takes a while, when we try to improve its interrupt latency, and when we need to deal with other concurrent interrupts during the ISR 23

Ξεκινώντας με ένα απλό παράδειγμα Keyboard command processing 24

Θα χαθούν events? 25

Βελτιώνοντας την καθυστέρηση Διακοπών Add a buffer (in software or hardware) for input characters. This decouples the time for processing from the time between keystrokes, and provides a computable upper bound on the time required to service a keyboard interrupt. 26

Τι μπορεί να πάει στραβά? 1. ο Buffer μπορεί να υπερχειλίσει (bigger buffer helps, but there is a limit) 2. Could another interrupt occur while adding the current keyboard character to the input_buffer? Result will depend upon whether interrupts have been enabled or not 27

Masking Interrupts If interrupts are masked (IRQ and FIQ disabled), nothing will be processed until the ISR completes and returns. 28

Επεξεργασία του buffer Απαιτείται προσοχή όταν τροποποιείται ο buffer όταν τα interrupts είναι ενεργοποιημένα 29