1 / 59

Operating Systems

Operating Systems. Mehdi Naghavi naghavi@iust.ac.ir naghavi@aut.ac.ir Spring 1386. Class outline. Introduction and Overview Operating system structures Processes Scheduling Deadlocks Memory management Input/Output File Systems Security. Operating Systems. Input/Output Systems.

hafwen
Download Presentation

Operating Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating Systems Mehdi Naghavi naghavi@iust.ac.ir naghavi@aut.ac.ir Spring 1386

  2. Class outline • Introduction and Overview • Operating system structures • Processes • Scheduling • Deadlocks • Memory management • Input/Output • File Systems • Security

  3. Operating Systems Input/Output Systems Mehdi Naghavi naghavi@aut.ac.ir naghavi_mehdi@yahoo.com Spring 1386

  4. Input/Output Systems Mehdi Naghavi naghavi@aut.ac.ir Spring 1386

  5. Overview • Principles of I/O hardware • Principles of I/O software • I/O software layers • Disks • Clocks • Character-oriented terminals • Graphical user interfaces • Network terminals • Power management

  6. How fast is I/O hardware?

  7. I/O Hardware Outsideworld Videocontroller Hard drivecontroller USBcontroller Networkcontroller CPU Computer internals(inside the “box”) Memory

  8. A Typical PC Bus Structure

  9. Device controllers • I/O devices have components • Mechanical component • Electronic component • The electronic component is the device controller • May be able to handle multiple devices • Controller's tasks • Convert serial bit stream to block of bytes • Perform error correction as necessary • Make available to main memory

  10. Memory-Mapped I/O Memory 0xFFF… I/O ports 0 SeparateI/O & memoryspace Memory-mapped I/O Hybrid: bothmemory-mapped &separate spaces

  11. How is memory-mapped I/O done? • Single-bus • All memory accesses go over a shared bus • I/O and RAM accesses compete for bandwidth • Dual-bus • RAM access over high-speed bus • I/O access over lower-speed bus • Less competition • More hardware (more expensive…) CPU Memory I/O CPU Memory I/O This port allows I/O devicesaccess into memory

  12. Device I/O Port Locations on PCs (partial)

  13. Intercommunication between I/O devices & CPU • Pooling • Interrupt

  14. Polling • Determines state of device • command-ready • busy • Error • Busy-wait cycle to wait for I/O from device

  15. Interrupts • CPU Interrupt-request line triggered by I/O device • Interrupt handler receives interrupts • Maskable to ignore or delay some interrupts • Interrupt vector to dispatch interrupt to correct handler • Based on priority • Some nonmaskable • Interrupt mechanism also used for exceptions

  16. Hardware’s view of interrupts Bus How interrupts happens. Connections between devices and interrupt controller actually use interrupt lines on the bus rather than dedicated wires

  17. Interrupt-Driven I/O Cycle

  18. Intel Pentium Processor Event-Vector Table

  19. Direct Memory Access • Used to avoid programmed I/O for large data movement • Requires DMA controller • Bypasses CPU to transfer data directly between I/O device and memory

  20. Direct Memory Access (DMA) operation

  21. Six Step Process to Perform DMA Transfer

  22. Input/Output Systems Principles of I/O Software

  23. I/O software: goals • Device independence • Programs can access any I/O device • No need to specify device in advance (floppy, hard drive, or CD-ROM) • Uniform naming • Name of a file or device is a string or an integer • Doesn’t depend on the machine (underlying hardware) • Error handling • Done as close to the hardware as possible • Isolate higher-level software • Synchronous vs. asynchronous transfers • Blocked transfers vs. interrupt-driven • Buffering • Data coming off a device cannot be stored in final destination • Sharable vs. dedicated devices • disks are sharable • tape drives would not be

  24. Programmed I/O: printing a page Steps in printing a string

  25. Code for programmed I/O Writing a string to the printer using programmed I/O

  26. Interrupt-driven I/O copy_from_user (buffer, p, count); j = 0; enable_interrupts(); while (*printer_status_reg != READY) ; *printer_data_reg = p[0]; scheduler(); // and block user Code run by system call if (count == 0) { unblock_user(); } else { *printer_data_reg = p[j]; count--; j++; } acknowledge_interrupt(); return_from_interrupt(); Code run at interrupt time • Writing a string to the printer using interrupt-driven I/O • Code executed when print system call is made • Interrupt service procedure

  27. I/O using DMA copy_from_user (buffer, p, count); set_up_DMA_controller(); scheduler(); // and block user Code run by system call acknowledge_interrupt(); unblock_user(); return_from_interrupt(); Code run at interrupt time • Printing a string using DMA • code executed when the print system call is made • interrupt service procedure

  28. I/O Interface • I/O system calls encapsulatedevice behaviors in generic classes • Device-driver layer hides differences among I/O controllers from kernel • Devices vary in many dimensions • Character-stream or block • Sequential or random-access • Sharable or dedicated • Speed of operation • read-write, read only, or write only

  29. Characteristics of I/O Devices

  30. A Kernel I/O Structure

  31. Layers of I/O software User-level I/O software & libraries User Device-independent OS software Operatingsystem(kernel) Device drivers Interrupt handlers Hardware

  32. Interrupt handlers • Interrupt handlers are best hidden • Driver starts an I/O operation and blocks • Interrupt notifies of completion • Interrupt procedure does its task • Then unblocksdriver that started it • Perform minimalactions at interrupt time • Some of the functionality can be done by the driver after it is unblocked • Interrupt handler must • Saveregs not already saved by interrupt hardware

  33. Device drivers Userspace • Device drivers go between device controllers and rest of OS • Drivers standardize interface to widely varied devices • Device drivers communicate with controllers over bus • Controllers communicate with devices themselves Userprogram Kernelspace Rest of the OS Software Keyboarddriver Diskdriver Keyboardcontroller Diskcontroller Hardware Devices

  34. Device-independent I/O software • Device-independent I/O software provides common “library” routines for I/O software • Helps drivers maintain a standard appearance to the rest of the OS • Uniform interface for many device drivers for • Buffering • Error reporting • Allocating and releasing dedicated devices • Suspending and resuming processes • Common resource pool • Device-independent block size (keep track of blocks)

  35. Non-standard driver interfaces Why a standard driver interface? Standard driver interfaces

  36. Buffering device input Userspace Userspace Userspace Userspace Kernelspace Kernelspace Kernelspace Kernelspace 2 2 1 1 3 Unbufferedinput Buffering inuser space Buffer in kernelCopy to user space Double bufferin kernel

  37. Anatomy of an I/O request Layers of the I/O system and the main functions of each layer

  38. Disk drive structure head • Data stored on surfaces • Up to two surfaces per platter • One or more platters per disk • Data in concentric tracks • Tracks broken into sectors • 256B-1KB per sector • Cylinder: corresponding tracks on all surfaces • Data read and written by heads • Actuator moves heads • Heads move in unison sector platter track cylinder surfaces spindle actuator

  39. Disk drive specifics example

  40. Disk “zones” • Outside tracks are longer than inside tracks • Two options • Bits are “bigger” • More bits (transfer faster) • Modern hard drives use second option • More data on outer tracks • Disk divided into “zones” • Constant sectors per track in each zone • 8–20 (or more) zones on a disk

  41. Disk “addressing” • Millions of sectors on the disk must be labeled • Two possibilities • Cylinder/track/sector • Sequential numbering • Modern drives use sequential numbers • Disks mapsequential numbers into specific location • Mapping may be modified by the disk • Remap bad sectors • Optimize performance • Hide the exact geometry, making life simpler for the OS

  42. Disk Structure • Disk drives are addressed as large 1-dimensional arrays of logical blocks, where the logical block is the smallest unit of transfer. • The 1-dimensional array of logical blocks is mapped into the sectors of the disk sequentially. • Sector 0 is the first sector of the first track on the outermost cylinder. • Mapping proceeds in order through that track, then the rest of the tracks in that cylinder, and then through the rest of the cylinders from outermost to innermost.

  43. Building a better “disk” • Problem: CPU performance has been increasing exponentially, but disk performance hasn’t • Disks are limited by mechanics • Problem: disks aren’t all that reliable • Solution: distribute data across disks, and use some of the space to improve reliability • Data transferred in parallel • Data storedacross drives (striping) • Parity on an “extra” drive for reliability

  44. RAID Structure Stripe stripe stripe RAID 0 (Redundant Array of Inexpensive Disks RAID 1 (Mirrored copies) RAID 4 (Striped with parity: any disk failure can be masked, but bottleneck for parity disk) RAID 5 (Parity rotates through disks: how do you update blocks?)

  45. RAID Levels

  46. RAID Recovery • X4(i)=X3(i)(+) X2(i)(+) X1(i)(+) X0(i) • (+) :exclusive or • X1(i)= X4(i)(+) X3(i)(+) X2(i)(+) X0(i)

  47. CD-ROM recording • CD-ROM has data in a spiral • Hard drives have concentric circles of data • One continuous track: just like vinyl records! • Pits & lands “simulated” with heat-sensitive material on CD-Rs and CD-RWs

  48. Network-Attached Storage • Network-attached storage (NAS) is storage made available over a network rather than over a local connection (such as a bus) • NFS (Network File System, Sun) and CIFS (Common Internet Files Systems, MS Protocol) are common protocols • Implemented via remote procedure calls between host and storage • New iSCSI protocol uses IP network to carry the SCSI protocol

  49. Storage Area Network • Common in large storage environments (and becoming more common) • Multiple hosts attached to multiple storage arrays flexible

  50. Structure of a disk sector Preamble Data ECC • Preamble contains information about the sector • Sector number & location information • Data is usually 256, 512, or 1024 bytes • ECC (Error Correcting Code) is used to detect & correct minor errors in the data

More Related