Interrupt Timer I/O operations

Similar documents
Exceptions, Interrupts, and Timers

Lecture 6: Real-Time Timing + Real-Time Objects

Lab Manual for VxWorks

Real-Time Systems Hermann Härtig Real-Time Operating Systems Brief Overview

Real-Time Systems. Real-Time Operating Systems

The POSIX AIO interface consists of the following functions: Enqueue a write request. This is the asynchronous analog of write(2).

Lecture 3: Concurrency & Tasking

FYS4220 / RT-lab no SIGNALS

REAL-TIME OPERATING SYSTEMS SHORT OVERVIEW

Overview. POSIX signals. Generation of signals. Handling signals. Some predefined signals. Real-time Systems D0003E 3/3/2009

10. I/O System Library

Asynchronous Events on Linux

Time Handling in Programming Language

Any of the descriptors in the set {1, 4} have an exception condition pending

Semaphores. Chapter. verview inary Semaphores for Task Synchronization utex Semaphores to Solve Mutual Exclusion Problems

I/O Models. Kartik Gopalan

PEMP ESD2531. I/O and File System. Session Speaker. Deepak V. M.S Ramaiah School of Advanced Studies - Bengaluru

Real Time Operating Systems and Middleware

User-Space Debugging Simplifies Driver Development

Appendix Example Code

Implementation of a Single Threaded User Level Asynchronous I/O Library using the Reactor Pattern

Programming RT systems with pthreads

The control of I/O devices is a major concern for OS designers

ISA 563: Fundamentals of Systems Programming

VxWorks Kernel API Reference. VxWorks. KERNEL API REFERENCE Volume 1: Libraries 6.2

CS4514 Project 2 Help Session (B07) Feng Li Nov 8, 2007

Signals are a kernel-supported mechanism for reporting events to user code and forcing a response to them. There are actually two sorts of such

The Kernel Abstraction

The Design of TTCAN Bus Network Node Based on Embedded Operating System VxWorks

Real-Time Operating Systems

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year

A read or write being atomic means that its effect is as if it happens instantaneously.

Hardware OS & OS- Application interface

Parallel I/O Paradigms. Files and File Semantics. Non-Blocking I/O. Enabling Parallel Operations. Multi-Channel Poll/Select. Worker Threads 3/28/2017

Programming RT systems with pthreads

Micrium µc/os II RTOS Introduction EE J. E. Lumpp

Process Context & Interrupts. New process can mess up information in old process. (i.e. what if they both use the same register?)

Xinu on the Transputer

Module 12: I/O Systems

OPERATING SYSTEMS OVERVIEW. Operating Systems 2015 Spring by Euiseong Seo

GLOSSARY. VisualDSP++ Kernel (VDK) User s Guide B-1

Embedded System Curriculum

Computer Systems Assignment 2: Fork and Threads Package

Lecture 4: Real Time Semaphores

Interrupts Peter Rounce

Processes. Johan Montelius KTH

REAL-TIME MULTITASKING KERNEL FOR IBM-BASED MICROCOMPUTERS

A process. the stack

Interrupts Peter Rounce - room 6.18

Section 3: File I/O, JSON, Generics. Meghan Cowan

Module 12: I/O Systems

Implementation of the ART Real Time Micro Kernel

Embedded Systems. 5. Operating Systems. Lothar Thiele. Computer Engineering and Networks Laboratory

CS4514 HELP Session 2 Simulation of Datalink Layer Communication

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Real Time Operating System Support for Concurrency

Signals, Synchronization. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han

Real-Time Concepts for Embedded Systems Author: Qing Li with Caroline Yao

Systems Programming/ C and UNIX

Experiment #3 Semaphores

CS 550 Operating Systems Spring Interrupt

Input/Output Systems

NPRG051 Advanced C++ Programming 2016/17 Assignment 2

Tasks. Task Implementation and management

Chapter 13: I/O Systems

19: I/O. Mark Handley. Direct Memory Access (DMA)

MaRTE OS Misc utilities

Quadros. RTXC Kernel Services Reference, Volume 1. Levels, Threads, Exceptions, Pipes, Event Sources, Counters, and Alarms. Systems Inc.

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line

Embedded Software TI2726 B. 7. Embedded software design. Koen Langendoen. Embedded Software Group

Introduction to the Linux Kernel. Hao-Ran Liu

ArdOS The Arduino Operating System Reference Guide Contents

Lecture 15: I/O Devices & Drivers

Exam TI2720-C/TI2725-C Embedded Software

System Call. Preview. System Call. System Call. System Call 9/7/2018

FreeRTOS. A Brief Overview. Christopher Kenna. October 1, Avionics. FreeRTOS 1 / 34

Operating Systems 2010/2011

Concurrent Server Design Multiple- vs. Single-Thread

CEC 450 Real-Time Systems

3.1 Introduction. Computers perform operations concurrently

* What are the different states for a task in an OS?

2.5 Timers Continuous Clock Task Timers Application Timers Memory Management

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

CS 355 Operating Systems. Keeping Track of Processes. When are processes created? Process States 1/26/18. Processes, Unix Processes and System Calls

Introduction to Real-Time Operating Systems

OPERATING SYSTEMS ASSIGNMENT 2 SIGNALS, USER LEVEL THREADS AND SYNCHRONIZATION

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

CS 326: Operating Systems. Process Execution. Lecture 5

INTERRUPT MANAGEMENT An interrupt is a hardware mechanism used to service an event that can be external or internal to

The UtePC/Yalnix Memory System

Timers 1 / 46. Jiffies. Potent and Evil Magic

Linux Driver and Embedded Developer

Assignment 2 Group 5 Simon Gerber Systems Group Dept. Computer Science ETH Zurich - Switzerland

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Today: VM wrap-up Select (if time) Course wrap-up Final Evaluations

AUTOBEST: A United AUTOSAR-OS And ARINC 653 Kernel. Alexander Züpke, Marc Bommert, Daniel Lohmann


Transcription:

Interrupt vector table Interrupt service routine(isr) Usr ISR Interrupt Timer I/O operations Vector number hardware handler Handler: Save registers Call routine Restore registers RET myisr() Interrupts allow devices to notify the CPU that some event has occurred A user-defined routine can be installed to execute when an arrives This routine runs at time It is not a On-board timers are a common source of s Using them requires understanding s Absolute System- Wide Priority Interrupt Level (Hard Wired) Execution OrderControlled by Hardware Execution OrderControlled by Kernel Task Priority (Programmable) 1 2 Most architectures use a single dedicated stack Interrupt stack is allocated at system start-up The stack size is controlled by the macro INT_STACK_SIZE; default value defined in configallh Must be large enough for worst-case nesting Library Routines blib All routines errnolib errnoget(), errnoset() fpparchlib fppsave(), fpprestore() intlib intcontext(), intcount(), intvecset(), intvecget() intarchlib intlock(), intunlock() loglib logmsg() lstlib All routines except lstfree() No s can run until ISR has completed ISR s are restricted from using some VxWorks facilities In particular, they can t block: Can t call semtake( ) Can t call malloc( ) (uses semaphores) Can t call I/O system routines (eg, printf( )) mathalib All routines, if fppsave()/fpprestore() are used msgqlib msgqsend() pipedrv write() rnglib All routines except rngcreate() and rngdelete() selectlib selwakeup(), selwakeupall() semlib semgive() except mutual-exclusion semaphores, semflush() siglib kill() 3 4

Lib Suspend(), Resume(), PrioritySet(), PriorityGet(),IdVerify(), IdDefault(), IsReady(),IsSuspended(),Tcb() ticklib tickannounce(), tickset(), tickget() tylib tyird(), tyitx() vxlib vxtas(), vxmemprobe() wdlib wdstart(), wdcancel() Reads and writes memory-mapped I/O registers Communicates information to a by: Writing to memory Making non-blocking writes to a message queue Giving a binary semaphore Keep ISR s short, because ISR s: Delay lower and equal priority s Delay all s Can be hard to debug Avoid using floating-point operations in an ISR They may be slow User must call fppsave( ) and fpprestore( ) Try to off-load as much work as possible to some : Work which is longer in duration Work which is less critical To log diagnostic information to the console at time: logmsg ( foo = %d\n, foo, 0, 0, 0, 0, 0); Sends a request to tlogtask to do a printf( ) for us Similar to printf( ), with the following caveats: Arguments must be 4 bytes Format string plus 6 additional arguments Use a debugging strategy which provides system-level debugging: WDB agent Emulator 5 6 Cause a trap to the boot ROM s Logged messages will not be printed Boot ROM program will display an exception description on reboot An exception occurring in an ISR will generate a warm reboot Can use sprintf( ) to print diagnostic information to memory not overwritten on reboot, if necessary STATUS intconnect (vector, routine, param) vector The vector routine The address of the user-defined ISR param Any value to be passed to this ISR Example: #include "ivh" void myisr(); if (intconnect (INUM_TO_IVEC(intNum), myisr, 0) ==ERROR) return (ERROR); INUM_TO_IVEC (intnum) Converts an number to vector in an architecture dependent manner: On-board timers the CPU periodically Timers allow user-defined routines to be executed at periodic intervals, which is useful for: Polling hardware Checking for system errors Aborting an untimely operation VxWorks supplies a generic interface to manipulate two timers: System clock Auxiliary clock (if available) 7 8

System clock ISR performs book-keeping: Increments the tick count (use tickget( ) to examine the count) Updates delays and timeouts Checks for round-robin rescheduling These operations may cause a reschedule Default clock rate is 60hz sysclkrateset (freq) Sets the clock rate int sysclkrateget( ) Returns the clock rate sysclkrateset( ) should only be called at system startup To create a watchdog timer: WDOG_ID wdcreate ( ) Returns watchdog id, or NULL on error To start (or restart) a watchdog timer: STATUS wdstart (wdid, delay, proutine,parameter) wdid Watchdog id, returned from wdcreate( ) delay Number of ticks to delay proutine Routine to call when delay has expired parameter Argument to pass to routine User interface to the system clock Allows a C routine to execute after a specified time delay Upon expiration of delay, connected routine runs As part of system clock ISR Subject to ISR restrictions To use watchdogs for periodic code execution: wdid = wdcreate(); wdstart (wdid, DELAY_PERIOD, mywdisr, 0); void mywdisr(int param) doit (param); wdstart (wdid, DELAY_PERIOD, mywdisr, param); The doit( ) routine might: Poll some hardware device Unblock some Check if system errors are present 9 10 To recover from a missed deadline: WDOG_ID wdid; void foo(void) wdid = wdcreate( ); /* Must finish each cycle in under 10 seconds */ FOREVER wdstart (wdid, DELAY_10_SEC, fooisr, 0); foodowork( ); To cancel a previously started watchdog: STATUS wdcancel (wdid) To deallocate a watchdog timer (and cancel any previous start): STATUS wddelete (wdid) void fooisr (int param) /* Handle missed deadline */ Can poll at time or time Interrupt time polling is more reliable Task time polling has a smaller impact on the rest of the system To poll at time, there are two options: Delay( ) : faster, but may drift wdstart( ) + semgive( ) : more robust 11 12

For high speed polling, use the auxiliary clock Precludes using spy, which also uses the auxiliary clock Some routines to manipulate auxiliary clock: sysauxclkconnect( ) Connect ISR to Aux clock sysauxclkrateset( ) Set Aux clock rate sysauxclkenable( ) Start Aux clock sysauxclkdisable( ) Stop Aux clock int timer_settime ( timer_t timerid, int flags, const struct itimerspec * value, struct itimerspec * ovalue ) int nanosleep ( const struct timespec * rqtp,struct timespec * rmtp ) int timer_getoverrun ( timer_t timerid ) int timer_create (clockid_t clock_id, struct sigevent * evp, time_t * ptimer ) int timer_delete ( timer_t timerid /* timer ID */ ) time_t tv_sec seconds long tv_nsec nanoseconds (0-1,000,000,000) int timer_gettime ( timer_t timerid, struct itimerspec * value ) Only one clock_id is supported, the required CLOCK_REALTIME 13 14 struct timespec it_interval timer period (reload value) struct timespec it_value timer expiration it_value: Non-zero sets the next time Zero the timer is disarmed it_interval: Non-zero a periodic (or repetitive) timer is specified Zero: once Select() socket, tserver pipe or serial port select( ) allows a to wait for activity on a set of file descriptors Requires driver support: VxWorks pipes, sockets and serial device drivers support select( ) Third party drivers may also support select( ) Also used to pend with a timeout int open (name, flags, mode) flags: O_RDONLY, O_WRONLY, O_RDWR, O_TRUNC, O_CREAT mode: Permissions for NFS device STATUS close (fd) Tasks must close files when they are no longer needed File descriptor table is fixed size int read (fd, buffer, nbytes) int write (fd, buffer, nbytes) May block; returns number of bytes read or written int ioctl (fd, command, arg) Allows execution of a device specific command Valid ioctl() commands are listed in driver help page Used by select( ) to specify file descriptors Conceptually an array of bits, with bit N corresponding to file descriptor N Bits are manipulated via a collection of macros: FD_SET (fd, &fdset) Sets the bit FD_CLR (fd, &fdset) Clears the bit FD_ISSET (fd, &fdset) Returns TRUE if the fd bit is set, else FALSE FD_ZERO (&fdset) Clears all bits 15 16

int select (width, preadfds, pwritefds, pexceptfds, ptimeout) width Number of bits to examine in preadfds and pwritefds preadfds struct fd_set pointer for the file descriptors we wish to read pwritefds struct fd_set pointer for the file descriptors we wish to write pexceptfds Not implemented ptimeout Pointer to a struct timeval, or NULL to wait forever Returns number of active devices, or ERROR aio_fildes file descriptor for I/O aio_offset offset from the beginning of the file aio_buf address of the buffer from/to which AIO is requested aio_nbytes number of bytes to read or write aio_reqprio priority reduction for this AIO request aio_sigevent signal to return on completion of an operation (optional) aio_lio_opcode operation to be performed by a lio_listio() call aio_sys VxWorks-specific data (non-posix) aio_lio_opcode Valid entries include LIO_READ, LIO_WRITE, and LIO_NOP aiopxlibinit() Initialize the AIO library (non-posix) aio_read() Initiate an asynchronous read operation aio_write() Initiate an asynchronous write operation aio_listio() Initiate a list of up to LIO_MAX asynchronous I/O requests aio_error() Retrieve the error status of an AIO operation aio_return() Retrieve the return status of a completed AIO operation aio_cancel() Cancel a previously submitted AIO operation aio_suspend() Wait until an AIO operation is done, ed, or timed out 17 18