Lecture 8 Task Utilization. Theoretical Analysis.

Slides:



Advertisements
Similar presentations
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Advertisements

Computer Architecture
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
® 10-2 Exceptions, Interrupts, and Timers 10.1Exception Handling and Signals Interrupt Service Routines Timers.
EEE 435 Principles of Operating Systems Principles and Structure of I/O Software (Modern Operating Systems 5.2 & 5.3) 5/22/20151Dr Alain Beaulieu.
04/14/2008CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying the textbook.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
04/16/2010CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying an earlier edition.
Concurrency: Mutual Exclusion, Synchronization, Deadlock, and Starvation in Representative Operating Systems.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output – 3 I/O Software CS 342 – Operating Systems Ibrahim Korpeoglu.
CHAPTER 9: Input / Output
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
COMP201 Computer Systems Exceptions and Interrupts.
Interrupts Signal that causes the CPU to alter its normal flow on instruction execution ◦ frees CPU from waiting for events ◦ provides control for external.
CHAPTER 9: Input / Output
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
I/O Systems I/O Hardware Application I/O Interface
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
1 Comp 104: Operating Systems Concepts Devices. 2 Today Devices –Introduction –Handling I/O Device handling Buffering and caching.
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.
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.
FreeRTOS.
Device Drivers CPU I/O Interface Device Driver DEVICECONTROL OPERATIONSDATA TRANSFER OPERATIONS Disk Seek to Sector, Track, Cyl. Seek Home Position.
® 7-2 Semaphores 7.1Overview Binary Semaphores and Synchronization Mutual Exclusion.
NT Kernel CS Spring Overview Interrupts and Exceptions: Trap Handler Interrupt Request Levels and IRT DPC’s, and APC’s System Service Dispatching.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
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.
 Wind River Systems, Inc Chapter - 7 Intertask Communication.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 13: I/O Systems Overview I/O Hardware Application.
Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 I/O through system calls Protection.
Lecture 12 Page 1 CS 111 Online Using Devices and Their Drivers Practical use issues Achieving good performance in driver use.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
I/O Software CS 537 – Introduction to Operating Systems.
Part IVI/O Systems Chapter 13: I/O Systems. I/O Hardware a typical PCI bus structure 2.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Input/Output (I/O) Important OS function – control I/O
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
Topics Covered What is Real Time Operating System (RTOS)
Protection of System Resources
Computer Architecture
CSCI 315 Operating Systems Design
Module 2: Computer-System Structures
I/O Systems I/O Hardware Application I/O Interface
Operating Systems Chapter 5: Input/Output Management
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Direct Memory Access Disk and Network transfers: awkward timing:
Lecture 2 Part 2 Process Synchronization
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Intertask Communication
Module 2: Computer-System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

Lecture 8 Task Utilization

Theoretical Analysis

It means that 100,000,000 cycles are executed in 1 second.

Analysis of aperiodic events

Ineffective for high-priority, short-deadline aperiodic events. The handling of the event is delayed until the next polling cycle.

:

L(Tx) Tx = t2 – t1

Low Level Programming

Hardware Watchdog example Watchdog timer in VxWorks: -Allows C function to be connected to a specific time delay. -Is invoked as part of the system clock ISR, meaning that at the system’s clock interrupt level. All restrictions on ISRs apply to routines connected to watchdog timer. wdCreate() - create a watchdog timer wdDelete() - delete a watchdog timer wdStart() - start a watchdog timer wdCancel() - cancel a currently counting watchdog

In the fragment below, if maybeSlowRoutine( ) takes more than 60 ticks, logMsg() will be called with the string as a parameter, causing the message to be printed on the console. Normally, of course, more significant corrective action would be taken. WDOG_ID wid = wdCreate (); wdStart (wid, 60, logMsg, "Help, I've timed out!"); maybeSlowRoutine (); /* user-supplied routine */ wdCancel (wid);

Software Watchdog example void WdClass::Init() { taskSpawn( "tLX", /* task name */ WD_LO_TASK_PRIORITY, /* task priority */ NULL, /* task option word */ WD_TASK_STACK_SIZE, /* stack size (bytes) */ WdTaskFnGW, /* task entry point */ 0,0,0,0,0,0,0,0,0,0 ); /* optional params */ taskSpawn( "tHX", /* task name */ WD_LO_TASK_PRIORITY, /* task priority */ NULL, /* task option word */ WD_TASK_STACK_SIZE, /* stack size (bytes) */ WdTaskFnGW, /* task entry point */ 0,0,0,0,0,0,0,0,0,0 ); /* optional params */ }

STATUS WdClass::WdTaskFnGW( ) { return ( (*this)->WdTaskFn() ); } Software Watchdog example

STATUS WdClass::WdTaskFn() { while ( true ) { taskDelay( 2*SECOND ); // Wait between cycles // Check if task got cpu in last 'sw_wd_timeout_' seconds UINT32 now = tickGet(); UINT32 delta = (now - low_pr_task_act_time)/sysClkRateGet(); if( delta >= sw_wd_timeout_ ){ logMsg(“Help, I’ve timed out!”); taskDelay( SECOND ); } UINT32 now = tickGet(); low_pr_task_act_time = now; }

Software Watchdog example SysInit() { … WdClass software_watchdog; software_watchdog->Init(); … }

Device driver may ensure use by no more than one task at a time. Use Mutex, semaphore or message queue. Example: mutual exclusion for single device write operation. -Dev_Init() calls to sm_create() and sets initial value of semaphore to “available”. -Dev_Write() calls to sm_take() before the access to device. -Dev_Write() call to sm_give() after access to device. Mutual Exclusion for Device Access

Example 1: Synchronous I/O Model Calling task is blocked until I/O transaction is completed. All the other tasks or ISRs may execute. READ_OPERATION DEVICE_ISRBEGIN StartIODeviceOperation();HandleHardwareData(); semTake();semGive(); //wait for a signal//signal completion GetDeviceDataEND END

Example 2: Asynchronous I/O Model Calling task is not blocked while I/O is taking place. READ_OPERATION DEVICE_ISRBEGIN Rc=q_recv(D_IN, NOWAIT )TransferData; StartNextInputOperation;q_send(D_IN); Process D_IN data//send new dataEND

Example 3: Free Running Asynchronous Input Calling task is not blocked while I/O is taking place. But hardware can deliver inputs repeatedly without software request. READ_OPERATION DEVICE_ISRBEGIN Rc=q_recv(D_IN, NOWAIT )TransferData; Process D_IN data q_send(D_IN); //send new dataEND

Example 4: Handling Latest Input Only In previous examples an old data is taken. A data can be queued up and become very old. To solve we use protected shared data area. Protected shared data protects from access collisions using a Binary Semaphore. Data Area contains latest measured data only. Old data is overwritten. Input device hardware can be free running, giving interrupts whenever ready.

sem_take(mysm,SM_WAIT); Read data from shared data area; End access Sem_give(mysm) /*new data is available*/ sem_take(mysm,SM_NOWAIT); If semaphore OK, Write to shared data area End access; sem_give(mysm_ Else… EndIF

Example 5: Double Buffered Input Data One buffer being filled while the other being processed. Works OK if buffer processing completes before a new buffer is filled.

Example 6: Serial Input Data Spooler Characters arrive via individual interrupts. Get next message( q_receive() ) Return the buffer( pt_retbuf() ) Queue this message ( q_send() ) Request new buffer(pt_getbuf(NOWAIT))

Get next message( q_receive() ) Return the buffer( pt_retbuf() ) Send message ( q_send() ) Request new buffer(pt_getbuf(NOWAIT)) Direct DMA interface to new buffer Example 6: Zero Copy DMA Input Spooler Direct DMA interface to transfer data directly Return data block( de_read() ) /*Interrupt: current buffer full*/