Module 2.E Buffered I/O Tim Rogers 2017.

Slides:



Advertisements
Similar presentations
Data Structures Lecture 13: QUEUES Azhar Maqsood NUST Institute of Information Technology (NIIT)
Advertisements

CS-334: Computer Architecture
Chapter 7 Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats.
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
UQC113S2 Interrupt driven IO. We have already seen the hardware support required to facilitate interrupts We will now look at the higher levels of software.
Group 7 Jhonathan Briceño Reginal Etienne Christian Kruger Felix Martinez Dane Minott Immer S Rivera Ander Sahonero.
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
Chapter 7 Input/Output Luisa Botero Santiago Del Portillo Ivan Vega.
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Basic Systems and Software. Were we left off Computers are programmable (formal) machines. Digital information is stored as a series of two states (1.
Queues Chapter 5 Queue Definition A queue is an ordered collection of data items such that: –Items can be removed only at one end (the front of the queue)
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
© 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver.
Input Output Techniques Programmed Interrupt driven Direct Memory Access (DMA)
I/O Software CS 537 – Introduction to Operating Systems.
Queues Another Linear ADT Copyright © 2009 Curt Hill.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Queues 1. Introduction A sequential collection of data Changes occur at both ends, not just one Queue applications –files waiting to be printed –"jobs"
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
1 Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and.
Input/Output (I/O) Important OS function – control I/O
Review Array Array Elements Accessing array elements
Data Structures Using C, 2e
Queues.
ADT description Implementations
Process Management Process Concept Why only the global variables?
Topic 3 (Textbook - Chapter 3) Processes
Buffered, Interrupt-Driven Printer Design Example
Concurrency: Deadlock and Starvation
Fri. Sept 29 Announcements
Mon. Oct 2 Announcements Quiz Postponed to Wednesday – still only on 2.a + 2.b Video lecture for 2.a posted Lab 6 experiment extension You must come to.
9S12C Multiplexed Bus Expansion
Operating Systems (CS 340 D)
Input/Output.
Wed. Sept 20 Announcements
Buffered, Interrupt-Driven Printer Design Example
Lectures Queues Chapter 8 of textbook 1. Concepts of queue
Queues Queues Queues.
Lab Practical #1 Review Tim Rogers 2017.
Queues Chapter 8 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved
Chapter 8 I/O.
Computer Architecture
Applied Operating System Concepts
Module 2.E Buffered I/O Tim Rogers 2017.
Queues.
Concurrency: Mutual Exclusion and Synchronization
Processor Management Damian Gordon.
Computer System Overview
CPSC 457 Operating Systems
Graded Quiz #6 Oct. 13, 2017 Clicker [AB]
Operating Systems Chapter 5: Input/Output Management
Chapter 8 I/O.
Transmitter Interrupts
Computer Architecture and Assembly Language
Created by Vivi Sahfitri
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
Chapter 8 I/O.
Device Mgmt © 2004, D. J. Foreman.
Device Mgmt © 2004, D. J. Foreman.
Processor Management Damian Gordon.
Jazan University, Jazan KSA
Presentation transcript:

Module 2.E Buffered I/O Tim Rogers 2017

Learning Outcome #2 Bus Timing Analysis “An ability to interface a microcontroller to various devices” Bus Timing Analysis 9S12C Multiplexed Bus Expansion General-Purpose I/O Ports Interrupt Handling Buffered I/O Buffered, Interrupt-Driven Printer Design Example How?

Objective Why? “Buffered I/O” Devices are much slower than CPUs (yes – even the 9S12) Problems: Data production/consumption rates are different. CPU slowed by device. EX: CPU has a character to print - printer is busy, so CPU must wait. Data may be coming in to CPU before the CPU is ready to deal with it.

These simple relationship are called producer/consumer. Solution: A buffer For output devices - want the CPU to put data in a buffer as soon as it’s ready (don’t wait for the device to no longer be busy). Buffer Produce Data Consume Data These simple relationship are called producer/consumer.

These simple relationship are called producer/consumer. Solution: A Buffer For input devices - want the device to place data in a buffer as it’s produced. Then the CPU can grab it when the CPU is ready. Buffer Consume Data Produce Data These simple relationship are called producer/consumer.

Circular Buffers Space is finite and we do not have dynamic memory management (i.e. malloc/free or new/delete). Allocate a fixed size in memory, then “wrap around” Managed with a First in First Out (FIFO) policy.

Circular buffers 2 pointers manage buffer allocation and deallocation IN: points to next available location. Producer puts data here. OUT: points to next data item in FIFO order. Consumer takes data from here. We are going to manage the buffer with no other meta-data. IN OUT

Circular Buffers OUT IN Example: BufferSize = 8 Empty condition: IN == OUT

Circular Buffers A B C D OUT IN Example: BufferSize = 8 Content in buffer A B C D IN

(IN+1) mod BufferSize == OUT Can the buffer be full when OUT points to index 3 (A) Yes (B) No (C) I really can’t tell Can the buffer be full when OUT points to index 3 (A) Yes  (B) No (C) I really can’t tell Circular Buffers Example: BufferSize = 8 OUT Buffer Full: (IN+1) mod BufferSize == OUT A B Why? IN C G D E F

Circular Buffer Algorithms Spin-wait when buffer is full Producer process 1. Check state of buffer 2. If buffer is FULL, wait for space 3. Else, place character in buffer at location pointed to by IN 4. Increment IN pointer modulo BUFSIZE 5. Exit

Circular Buffer Algorithms Spin-wait when buffer is empty Consumer Process 1. Check state of buffer 2. If buffer is EMPTY, wait for data 3. Else, get data from location pointed to by OUT pointer 4. Increment OUT pointer modulo BUFSIZE 5. Exit