CS 326 Operating Systems Fall 2004 Professor Allan B. Cruse University of San Francisco.

Slides:



Advertisements
Similar presentations
System Integration and Performance
Advertisements

The IDE/ATA Interface How can our mini-Operating System, executing in protected mode, access the hard disk?
The ATA/IDE Interface Can we write a character-mode device driver for the hard disk?
CS-334: Computer Architecture
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
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.
The IDE/ATA Interface How can our mini-Operating System, executing in protected mode, access the hard disk?
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Computer Organization and Assembly language
1/21/2010CSCI 315 Operating Systems Design1 Computer System Structures Notice: The slides for this lecture have been largely based on those accompanying.
1 Today I/O Systems Storage. 2 I/O Devices Many different kinds of I/O devices Software that controls them: device drivers.
I/O Systems CSCI 444/544 Operating Systems Fall 2008.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Input / Output CS 537 – Introduction to Operating Systems.
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
1 Computer System Overview Let’s figure out what’s inside this thing...
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Operating System. Architecture of Computer System Hardware Operating System (OS) Programming Language (e.g. PASCAL) Application Programs (e.g. WORD, EXCEL)
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
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.
Chapter 1 Computer System Overview Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 Chapter 13: I/O Systems I/O Hardware.
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
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS6: Device Management 6.1. Principles of I/O.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
I/O Example: Disk Drives To access data: — seek: position head over the proper track (8 to 20 ms. avg.) — rotational latency: wait for desired sector (.5.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
Guide to Linux Installation and Administration, 2e1 Chapter 2 Planning Your System.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Chapter 13: I/O Systems. 13.2/34 Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware.
Fall 2000M.B. Ibáñez Lecture 25 I/O Systems. Fall 2000M.B. Ibáñez Categories of I/O Devices Human readable –used to communicate with the user –video display.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
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.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 13: I/O Systems Overview I/O Hardware Application.
Review of Computer System Organization. Computer Startup For a computer to start running when it is first powered up, it needs to execute an initial program.
Input Output Techniques Programmed Interrupt driven Direct Memory Access (DMA)
بسم الله الرحمن الرحيم MEMORY AND I/O.
I/O Software CS 537 – Introduction to Operating Systems.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Introduction to Operating Systems Concepts
Chapter 2: Computer-System Structures(Hardware)
Chapter 2: Computer-System Structures
Operating Systems (CS 340 D)
CS703 - Advanced Operating Systems
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Computer Science I CSC 135.
Module 2: Computer-System Structures
Operating Systems Chapter 5: Input/Output Management
CS703 - Advanced Operating Systems
Module 2: Computer-System Structures
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
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 2: Computer-System Structures
Lecture 12 Input/Output (programmer view)
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

CS 326 Operating Systems Fall 2004 Professor Allan B. Cruse University of San Francisco

Instructor Contact Information Office: Harney Science Center – 212 Hours: M-W 2:45-3:15, Tu-Th 1:30-2:30 Phone: (415) Webpage: cs.usfca.edu/~cruse

Course Textbooks William Stallings, Operating Systems: Internals and Design Principles (5 th Ed), Pearson Prentice-Hall, Inc (2005) Gary Nutt, Kernel Projects for Linux, Addison-Wesley Longman, Inc (2001)

Course Synopsis We study modern operating systems: –Design Issues –Data structures –Internal Algorithms We focus on microcomputer examples: –MS Windows –UNIX/Linux We do “hands-on” programming exercises

Prerequisites Ability to do programming in C Language Understand Intel x86 Assembly Language Knowledge of Standard Data Structures Familiarity with basic UNIX commands This background corresponds to USF’s freshman-sophomore course-sequence: CS110, CS112, CS210, CS245

Assigned Readings Week 1: read Gary Nutt’s “Overview” Weeks 2-14: read chapter from Stallings (as specified in printed course-syllabus) Class Lectures will cover supplementary material, intended to clarify ideas in texts Class Exercises will apply these general principles by doing practical programming

Computer Hardware Components CPU Memory system bus I/O device I/O device I/O device I/O device...

Background Earliest computer programs ran on a “bare machine” (i.e., no separate OS software) These programs had to control I/O devices as well as perform their computations But writing software to control devices is very demanding on human programmers (e.g., requires specialized knowledge of each device’s design and idiosyncrasies) Tediously repetitive for each new program

Solution: software ‘reuse’ It was crazy to rewrite the complex device control software over and over again with for every new computing task Better to separate the specialized device- control software from the application code The ‘old’ device-control software could be reused with a ‘new’ application – provided there was a way to ‘link’ the two together This insight was the genesis for the OS

System Organization Hardware Operating System software Application software

Modern Operating Systems Several ambitious goals for today’s OS’s Allow multiple application programs to be executed at the same time, each sharing access to the devices, yet not interfering with one another (i.e., protection) Allow multiple users on the same system Provide fairness in system access policies Support ‘portability’ and ‘extensibility’

A Modern OS Design Hardware Application Shared Runtime Libraries user-mode supervisor-mode System Call Interface Device Driver Components memory manager task manager file manager network manager OS Kernel

Linux Device Programming Application programs normally are not allowed to program I/O devices directly But Linux lets ‘privileged’ users disable this built-in ‘protection’ feature We can take advantage of this capability, to show exactly what’s involved in writing software that directly controls i/o hardware This gives insight into what an OS does!

Device Characteristics Each device-type involves different details But most have a few aspects are common There’s a way for the CPU to issue device commands (e.g., turn device on/off, etc) There’s a way for the CPU to detect the device’s current status (e.g., busy, ready) There’s a way to perform transfers of data There’s a way the device can send signals

I/O Ports On Intel x86 systems (such as ours): –CPU communicates with devices via ‘ports’ –Ports provide access to device-registers –So ‘ports’ are similar to memory-locations –Ports have addresses, and can store values –Special instructions exist for accessing ports –The ‘IN’ instruction reads from a port –The ‘OUT’ instruction writes to a port – On a PC, port-addresses are 16-bit numbers

Important example: Hard Disks Our classrooms and labs have PCs that use IDE fixed-disks for storage of files IDE means ‘Intelligent Drive Electronics’ The programming interface for IDE drives conforms to an official documented ANSI standard (American National Standards Institute) We present enough details for an example

‘IDENTIFY DRIVE’ There exist about 40 different commands (e.e., read, write, seek, format, sleep, etc) Some are ‘mandatory’, others ‘optional’ An example: the ‘Identify Drive’ command It provides information on disk’s geometry and some other operational characteristics It identifies the disk’s manufacturer and it provides a unique disk serial-number

IDE Command Protocol IDE Commands typically have 3 phases: –COMMAND PHASE: CPU issues a command –DATA PHASE: data moves to/from IDE buffer –RESULT PHASE: CPU reads status/errors

The IDE Controller IDE Controller CPU system bus Slave Drive (Drive 1) Master Drive (Drive 0) optional Memory

Some IDE Device Registers Command Register 8-bits, write-only port 0x01F7 Status Register 8-bits, read-only port 0x01F7 Drive-Head Register 8-bits, read/write port 0x01F6 Error Register 8-bits, read-only port 0x01F1 Data Register 16-bits, read/write port 0x01F0 NOTE: Not shown are several additional special-purpose IDE device-registers.

IDE Drive-Head Register 1L1 DRV (0/1) HS3HS2HS1HS0 Legend: L = Linear Addressing (1=yes, 0=no) DRV = Drive selection (0=Master, 1=Slave) HS3..HS0 = Head Selection (0..15)

IDE Status Register (0x1F7) BSYDRDYDFDSCDRQCORRIDXERR Legend: BSY = Controller is busy DRDY = Controller is ready for new command DF = Drive Fault occurred DSC = Seek operation has completed DRQ = Data-Transfer Requested CORR = Data-Error was corrected IDX = Index Mark is detected ERR = Error information available

IDE Error Register (0x1F1) BBKUNCMCIDNFMCRABRTTK0NFAMNF Legend: BBK = Bad Block detected UNC = Uncorrectable Data-Error MC = Media Changed IDNF = ID Mark Not Found MCR = Media Change Requested ABRT = Command was Aborted TK0NF = Track 0 Not Found AMNF = Address Mark Not Found

COMMAND PHASE Wait until the IDE controller is ‘not busy’ Disable interrupts (to prevent preemption) Confirm ‘drive ready’ status Issue the ‘IDENTIFY DRIVE’ command (i.e., output byte 0xEC to port 0x01F7)

DATA-TRANSFER PHASE Continuously poll the Status Register until the DRQ bit is set, indicating that the data has been transferred into the controller’s internal ‘sector-buffer’ (size is 256 words) Read the IDE Data-Register 256-times, saving the values into a memory area

RESULT PHASE Verify that the DRQ status-bit is now clear, indicating Data-Transfer Phase is finished Check the ERR status-bit, to see if errors occurred, and if so, read the Error Register to obtain details about what went wrong Re-enable interrupts (so multitasking can resume)

Demo: ‘idnumber.cpp’ On our course website is a demo-program that uses the IDE ‘Identify Drive’ command to obtain and print the Disk Serial-Number You can compile and execute this program on your student workstation: compile using: $ make idnumber execute using: $./idnumber Everyone will see a different serial-number

In-class Exercise You can add your own code to this demo, so it will display useful information about the disk’s storage capacity and geometry You’ll need some ANSI documentation Try showing: –Number of Disk Cylinders –Number of Disk Heads –Number of Sectors-per-Track –Total disk storage-capacity (in megabytes)