Operating System. Hanyang University. Hyunmin Yoon Operating System Hanyang University

Similar documents
Operating System. Hanyang University. Hyunmin Yoon Operating System Hanyang University

Embedded Operating Systems

ECE 598 Advanced Operating Systems Lecture 11

Systems Architecture The ARM Processor

ECE 598 Advanced Operating Systems Lecture 7

ARM Advanced Interrupt Controller

Cooperative Multitasking

The ARM instruction set

ARM ARCHITECTURE. Contents at a glance:

Interrupt-Driven Input/Output

ECE 598 Advanced Operating Systems Lecture 8

Input/Output. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ARM Processors ARM ISA. ARM 1 in 1985 By 2001, more than 1 billion ARM processors shipped Widely used in many successful 32-bit embedded systems

Lecture 10 Exceptions and Interrupts. How are exceptions generated?

Interrupts Peter Rounce

DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM

ECE 598 Advanced Operating Systems Lecture 8

Hi Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan

ECE 341. Lecture # 19

18-349: Introduction to Embedded Real-Time Systems

Design and Implementation Interrupt Mechanism

October, Saeid Nooshabadi. Overview COMP 3221

Interrupts Peter Rounce - room 6.18

ARM Programmer s Model

CISC RISC. Compiler. Compiler. Processor. Processor

Operating systems and concurrency B02

CprE 288 Translating C Control Statements and Function Calls, Loops, Interrupt Processing. Instructors: Dr. Phillip Jones Dr.

Agenda. ARM Core Data Flow Model Registers Program Status Register Pipeline Exceptions Core Extensions ARM Architecture Revision

Returning from an Exception. ARM Exception(Interrupt) Processing. Exception Vector Table (Assembly code) Exception Handlers (and Vectors) in C code

An overview of Interrupts ECE3534

ARM Embedded Systems: ARM Design philosophy, Embedded System Hardware, Embedded System Software

AN HONORS UNIVERSITY IN MARYLAND UMBC. AvrX. Yousef Ebrahimi Professor Ryan Robucci

3 Assembly Programming (Part 2) Date: 07/09/2016 Name: ID:

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ECE251: Thursday September 27

Homework / Exam. Return and Review Exam #1 Reading. Machine Projects. Labs. S&S Extracts , PIC Data Sheet. Start on mp3 (Due Class 19)

VE7104/INTRODUCTION TO EMBEDDED CONTROLLERS UNIT III ARM BASED MICROCONTROLLERS

Chapter 09. Programming in Assembly

CPUs. Input and output. Supervisor mode, exceptions, traps. Co-processors. Computers as Components 4e 2016 Marilyn Wolf

ARM Interrupts. EE383: Introduction to Embedded Systems University of Kentucky. James E. Lumpp

Samsung S3C4510B. Hsung-Pin Chang Department of Computer Science National Chung Hsing University

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

Fully Preemptive nxtosek Kernel with Preemption Threshold Scheduling

The Operating System (OS) MicroComputer Engineering OperatingSystem slide 1!

Architectural Support for Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

3.1 Introduction. Computers perform operations concurrently

Chapter 15. ARM Architecture, Programming and Development Tools

EECS 373 Midterm Winter 2012

Wireless Sensor Networks (WSN)

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text

OPERATING SYSTEM OVERVIEW

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 12 Processor Structure and Function

Processes. Dr. Yingwu Zhu

Lecture 4: Process Management

ARM Architecture (1A) Young Won Lim 3/20/18

EEL 4744C: Microprocessor Applications. Lecture 7. Part 1. Interrupt. Dr. Tao Li 1

Reading Assignment. Interrupt. Interrupt. Interrupt. EEL 4744C: Microprocessor Applications. Lecture 7. Part 1

Input / Output. School of Computer Science G51CSA

Operating Systems. Part 8. Operating Systems. What is an operating system? Interact with Applications. Vector Tables. The master software

Lecture 25: Interrupt Handling and Multi-Data Processing. Spring 2018 Jason Tang

Operating Systems. System calls. Guillaume Salagnac. Fall Insa-Lyon IST Semester

Modes and Levels. Registers. Registers. Cortex-M3 programming

ARM Processor. Dr. P. T. Karule. Professor. Department of Electronics Engineering, Yeshwantrao Chavan College of Engineering, Nagpur

Hercules ARM Cortex -R4 System Architecture. Processor Overview

Context Switching & Task Scheduling

Boot Loader of Creator S3C4510 張大緯 CSIE, NCKU

ECE254 Lab3 Tutorial. Introduction to Keil LPC1768 Hardware and Programmers Model. Irene Huang

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

Processes and Threads. Processes and Threads. Processes (2) Processes (1)

COEN-4720 Embedded Systems Design Lecture 4 Interrupts (Part 1) Cristinel Ababei Dept. of Electrical and Computer Engineering Marquette University

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

Multitasking on Cortex-M(0) class MCU A deepdive into the Chromium-EC scheduler

EKT222 Miroprocessor Systems Lab 5

Free-RTOS Implementation

ARM Architecture and Assembly Programming Intro

I/O - input/output. system components: CPU, memory, and bus -- now add I/O controllers and peripheral devices. CPU Cache

AC OB S. Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014

Putting it All Together

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

Interrupt handling. Purpose. Interrupts. Computer Organization

Interrupts and Low Power Features

EE Embedded Systems Design. Lessons Exceptions - Resets and Interrupts

Interrupt/Timer/DMA 1

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text

CSC227: Operating Systems Fall Chapter 1 INTERRUPTS. Dr. Soha S. Zaghloul

Computer Systems II. First Two Major Computer System Evolution Steps

The ARM Instruction Set

Microprocessors & Interfacing

The ARM Cortex-M0 Processor Architecture Part-1

Interrupts (I) Lecturer: Sri Notes by Annie Guo. Week8 1

Operating systems and concurrency B02

Student ID: For examiner use

Xuan Guo. Lecture XIX: Subroutines (2) CSC 3210 Computer Organization and Programming Georgia State University. March 31, 2015.

Operating Systems. Introduction & Overview. Outline for today s lecture. Administrivia. ITS 225: Operating Systems. Lecture 1

Lecture 3: Instruction Set Architecture

embos Real Time Operating System CPU & Compiler specifics for ARM core with ARM RealView Developer Suite 3.0 Document Rev. 1

Lecture 3: Processes. CMPUT 379, Section A1, Winter 2014 January 13, 15 and 17

Fundamentals of ARMv8-A

The Kernel Abstraction. Chapter 2 OSPP Part I

Input Output (IO) Management

Transcription:

Hyunmin Yoon (fulcanelli86@gmail.com)

2 Interrupt vs. Polling INTERRUPT 2

3 Polling (Programmed I/O) Processor has direct control over I/O Processor waits for I/O module to complete operation Processor determines state of device Command-ready Busy Error Busy-wait cycle to wait for I/O 3

4 Interrupt (Interrupt-driven I/O) 1. Processor issues commands for I/O operations 2. Processor does other work while I/O devices do the operations 3. I/O devices send hardware interrupt signal to processor when they complete the operations 4. Processor stops the work, and then starts ISR (interrupt service routine) 5. Processor redo the work that is stopped by interrupt 4

5 Interrupt USR IRQ interrupt stop current work ISR return to previous work 5

6 Interrupt Service Routine ARM PROCESSOR FUNDAMENTALS #3 6

7 Registers Register size 32 bits 18 Active registers 16 data registers (r0 to r15) 2 processor status registers CPSR = current psr SPSR = saved psr 20 Banked registers ARM System Developer s Guide 7

8 Processor Status Register ARM System Developer s Guide 8

9 Mode Switch (1) Mode switch by Hardware when the core responds to an exception or interrupt Software that writes directly to the mode bits of cpsr Except USR mode Banked register All processor modes have a set of associated banked registers Except SYS mode A banked register maps one-to-one onto a USR mode register 9

10 Mode Switch (2) Example : When processor changes from USR mode to IRQ mode cpsr of previous mode (USR) is automatically saved into spsr of the next mode (IRQ) Return address is saved into r14_irq Processor read r13 and r14 of the current mode when it accesses them PRE : r0 = 0x00, r13 = 0x10, r13_irq = 0x20, cpsr = IRQ mode mov r0, r13 POST : r0 = 0x20, r13 = 0x10, r13_irq = 0x20, cpsr = IRQ mode 10

11 Vector Table When an exception or interrupt occurs Suspend normal execution Set the pc to a specific memory address ARM System Developer s Guide Start address of vector table can be changed (rose/hal/kernel/entry-armv.s) 11

12 ISR (timer) (rose/hal/kernel/entry-armv.s) (rose/hal/irq/gic.c) interrupt from device (rose/hal/io/timer.c) (rose/hal/kernel/entry-armv.s) 12

13 Write codes for the return from ISR to user application HOMEWORK #1 13

14 Homework #1 Complete vector_irq and ret_to_usr rose/hal/kernel/entry-armv.s Do not use branch instructions 14

15 Purpose USR IRQ Consider that processor runs counting program as below interrupt stop current work ISR void main(void) { unsigned int cnt = 0; while(1) cnt++; } return to previous work And, timer interrupt request is generated during the program execution Processor register has cnt value But, that register is using on ISR also -> cnt value will be corrupted OS has to restore previous program execution states including cnt value before the return from ISR 15

16 Process Control Block (rose/kernel/sched.c) point at PCB of current program task_struct (rose/hal/kernel/entry-armv.s) task_struct PCB List task_struct (rose/include/rose/sched.h) Memory 16

17 H1-A Save context 1. Save r0-r12 of USR mode onto reg[r0]-reg[r12] 2. Save cpsr of USR mode onto reg[cpsr] 3. Save return address (from IRQ to USR) onto reg[ret] r0~r12 of USR address lr+80 lr+76 lr+72 lr+68 lr+64 value class state pid alloc reg[ret] lr+60 lr+56 reg[cpsr] reg[lr] task_struct lr+52 reg[sp] address value lr+48 reg[12].. cpsr of USR sp Return Address lr lr+8 lr+4 reg[r2] reg[r1] reg[r0] MEMORY MEMORY 17

18 H1-B Restore context 1. Make stack area and fill it for RFE instruction by using reg[cpsr] and reg[ret] 2. Restore r0-r12 of USR mode by using reg[r0]-reg[r12] address sp cpsr_usr Return Address value r0~r12 of USR cpsr of USR address lr+80 lr+76 lr+72 lr+68 lr+64 lr+60 lr lr+56 lr+52 lr+48 lr+8 lr+4 value class state pid alloc reg[ret] reg[cpsr] reg[lr] reg[sp] reg[12].. reg[r2] reg[r1] reg[r0] task_struct MEMORY MEMORY 18

19 Result (1) Now, we can use shell program 19

20 Result (2) Do Not Use This Command! It will work after Homework #2 20