i o systems
play

I/O SYSTEMS Sunu Wibirama Are you surely IT class member? Then - PowerPoint PPT Presentation

I/O SYSTEMS Sunu Wibirama Are you surely IT class member? Then you should know these pictures... Introduction Main job of computer : I/O and processing (the latter is rarely happened) Browsing: read and enter information, not


  1. I/O SYSTEMS Sunu Wibirama

  2. Are you surely IT class member? Then you should know these pictures...

  3. Introduction  Main job of computer : I/O and processing (the latter is rarely happened)  Browsing: read and enter information, not compute an answer  OS: manage, control I/O devices and operations  We will explore:  I/O Hardware  Application I/O Interface  Kernel I/O Subsystem  Transforming I/O Requests to Hardware Operations  STREAMS  Performance  At the end of this presentation, we will talk about final assignment and final test (UAS) 13.

  4. I/O Hardware  Major concern of OS designer is: I/O support  Incredible variety of I/O devices: mouse, hard disk, cd-rom, usb, etc .  Common concepts of I/O hardware elements:  Port / connection point (ex.: serial port, parallel port)  Bus: wires with spesific protocol  Controller ( host adapter ) - Serial-port controller v.s. SCSI controller  Details are encapsulated in device-driver module in OS kernel  Device drivers: uniform I/O instructions to control I/O devices  Controller has one or more registers for data and control signals  Devices have addresses, used by  Direct I/O instructions using bus: send instructions to an I/O port address  Memory-mapped I/O: device-control registers are mapped into the address space of the processor 13.

  5. A Typical PC Bus Structure 13.

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

  7. I/O Port’s Register  Data-in register: read by the host to get input  Data-out register: written by the host to send output  Status register: contain status bits that can be read by the host  Control register: can be written by the host to start command or to change the mode of the device. Example:  Full-duplex or half-duplex mode;  Duplex: communicate (send and receive message). Half-duplex : only one activity at one time. Full-duplex : can either send or receive information at the same time. 13.

  8. Polling  Explain I/O host and I/O controller communication  Controller:  Status register: 1 - busy and 0 - clear  Host:  Command register: command-ready bit  Handshaking step (repeated for each byte):  Host repeatedly read busy bit until that bit becomes clear (busy waiting or polling)  Host sets the write bit in the command register and writes a byte into the data-out register  Host sets command-ready bit  Controller notices that command-ready bit is set, it sets the busy bit  Controller reads the command register, sees the write command. It reads data-out register to get the byte and does the I/O to the device  Controller clears command-ready bit, clears error bit in the status register to indicate I/O succeeded, clears the busy bit to indicate that I/O operation is finished  Busy-wait cycle to wait for I/O from device  More efficient, if the controller notify the CPU when it ʼ s ready to operate: interrupts 13.

  9. Interrupt-Driven I/O Cycle 13.

  10. Interrupts  Interrupts-request line: receiving interrupts from I/O contoller  Nonmaskable interrupt: reserved for events such as unrecoverable memory errors.  Maskable to ignore or delay some interrupts  Interrupt mechanism accepts an address - a number that selects a specific interrupt-handling routine from a small set (the number is called interrupt-vector )  Interrupt-vector contains the memory address of specialized interrupt-handlers.  Interrupt mechanism uses interrupt priority level (low or high priority interrupt)  Interrupt mechanism also used for exceptions (such as: dividing by zero, accessing protected or nonexistent memory address, attempting to execute a privileged instruction from user mode). 13.

  11. Direct Memory Access  Large data transfer: disk drive  Used to avoid programmed I/O for large data movement (= watch status bits and to feed data into a controller register one byte at a time)  Requires DMA controller  Bypasses CPU to transfer data directly between I/O device and memory 13.

  12. Six Step Process to Perform DMA Transfer 13.

  13. Application I/O Interface  Explain interface and techniques of OS to treat I/O devices in standard way (such as open a file on a disk without knowing what kind of disk it is).  I/O system calls encapsulate device 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 13.

  14. A Kernel I/O Structure uniformity think the structure as organization structure: head of organization doesn’t need to know the detail 13.

  15. Characteristics of I/O Devices 13.

  16. Kernel I/O Subsystem  Kernel provides many services to I/O, such as:  scheduling  buffering  caching  spooling  device reservation  error handling  These are provided by I/O subsystem, build on hardware and device-driver infrastructure 13.

  17. Kernel I/O Subsystem  Scheduling  Meaning: to determine a good order to execute I/O requests  Can improve overall system performance  Some I/O request ordering via per-device queue  Some OSs try fairness  Buffering - store data in memory while transferring between devices  To deal with device speed mismatch ( modem v.s. storage )  To deal with device transfer size mismatch (data re-assemble)  To maintain “copy semantics” (data reliability when write() system call is executed). 13.

  18. Sun Enterprise 6000 Device-Transfer Rates 13.

  19. Kernel I/O Subsystem  Caching - fast memory holding copy of data (do you remember the function of proxy server in networking? - you need to press CTRL+F5 to renew the cache )  Always just a copy (not the only existing item - as buffer does)  Key to performance  Spooling - hold output for a device  If device can serve only one request at a time  i.e., Printing - no interleave allowed  Device reservation - provides exclusive access to a device  System calls for allocation and deallocation  Watch out for deadlock 13.

  20. Error Handling  OS can recover from disk read, device unavailable or defective, transient write failures  Most return an error number or code when I/O request fails  Unix : errno 2 - no such file or directory  System error logs hold problem reports 13.

  21. I/O Protection  User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions  All I/O instructions defined to be privileged: I/O must be performed via OS ʼ system calls  Memory-mapped and I/O port memory locations must be protected too (ex.: graphic games and video editing should access the memory directly. OS should protects a block of memory for graphic processing at one time) 13.

  22. Kernel Data Structures  Kernel keeps state info for I/O components, including open file tables, network connections, character device state  Many, many complex data structures to track buffers, memory allocation, “dirty” blocks  Unix uses object-oriented methods to encapsulate “differences” (for example: read() operation, the semantics is different for each I/O devices)  Windows uses message passing to implement I/O  I/O request is converted into a message through the kernel to the I/O manager and then to device driver, each of which may change the message contents. For output, the message contains data to be written. For input, the message contains buffer to receive data. 13.

  23. I/O Requests to Hardware Operations  Consider reading a file from disk for a process:  Determine device holding file  Translate name to device representation  Physically read data from disk into buffer  Make data available to requesting process  Return control to process 13.

  24. Next week: Security

  25. Final Assignment

Recommend


More recommend