1 / 24

EEE 435 Principles of Operating Systems

EEE 435 Principles of Operating Systems. Principles of I/O Hardware – OR – Computer Hardware Review Review (Modern Operating Systems 5.1). Quick Review. What are the advantages of a segmented system? What are the two major disadvantages of a “pure” segmentation implementation?. Outline.

asher
Download Presentation

EEE 435 Principles of 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. EEE 435Principles of Operating Systems Principles of I/O Hardware – OR – Computer Hardware Review Review (Modern Operating Systems 5.1)

  2. Quick Review • What are the advantages of a segmented system? • What are the two major disadvantages of a “pure” segmentation implementation? Capt MWP LeSauvage

  3. Outline • I/O Device Categories • Device Controllers • Control Registers • Port-based I/O • Memory-Mapped I/O • Direct Me Interrupts mory Access Capt MWP LeSauvage

  4. I/O Device Categories • I/O Devices come in two general types: • Block devices • Character devices • Block devices store data in fixed-sized blocks, each with their own address • Disks are the “poster boy” of block devices • Since each block is addressable, each block may be read/written independently of the other blocks • ie: when you save a file to disk, you don’t have to read in and re-write your entire hard drive! Capt MWP LeSauvage

  5. I/O Device Categories • Character devices deliver/accept a stream of characters without regard to structure • Not addressable • No seek operation • Examples: mice, printers, network interfaces/modems • Some devices straddle the boundary: tape backup is storing/retrieving “blocks” of disk data, but does so sequentially Capt MWP LeSauvage

  6. Device Controllers • Recall: I/O devices typically have a mechanical component and a electronic component • The electronic part is the controller Monitor Capt MWP LeSauvage Bus

  7. Device Controllers • On a PC, the device controller is usually a printed circuit card • It may be integrated with the motherboard • The job of the controller is to convert the serial bit stream into a block of bytes and perform any correction necessary Capt MWP LeSauvage

  8. Control Registers • Each controller has a number of registers so it can be provided with instructions/work • The operating system can command the device to deliver data, accept data, turn off, etc • The OS can read the register to determine state • Controllers typically have a data buffer to which the OS can read/write • Important so incoming data is not lost • Sometimes used as “part” of the device, ie: video RAM to which programs can write for display Capt MWP LeSauvage

  9. Control Registers • How does the OS communicate with these registers/data buffers? Two Methods: • Special port numbers which must be specified • Mapping the registers to memory location Capt MWP LeSauvage

  10. Port-based I/O • To communicate to device controllers through ports, special commands must be available on the system • ie: use MOV assembly language command to talk to memory, but IN or OUT to talk to ports • Early computers all used this method • Disadvantages: • special instructions are required • Assembly code will be needed when writing functions that talk to devices. • Special code needed to protect I/O devices Capt MWP LeSauvage

  11. Memory-Mapped I/O • In this scheme, device control registers are mapped into the address space of the machine • Now, no unique instructions are required to talk to device controllers. Treat like any other I/O request • Advantages: • No new instructions required. In fact, some instructions can be used to test device status! • No special protection mechanisms needed (just protect the segment/page containing the I/O addresses) Capt MWP LeSauvage

  12. Memory-Mapped I/O • Disadvantages: • Caching is now difficult. We need a scheme that will not cache certain pages/segments or the OS will not see the state of the device change! • On each memory reference each memory module and I/O device must check to see if they are to respond to the request. This is trivial in the case of a system with a simple bus... Capt MWP LeSauvage

  13. Memory-Mapped I/O • Disadvantages (continued): • ...however, most systems provide a high speed bus between the CPU and memory and a system bus: • this makes it difficult for a device to see if it has been addressed. A system must be developed to forward the device addresses to the system bus in case the reference is to I/O and not memory Capt MWP LeSauvage

  14. Device Controller Round-Up Solutions: Separate Shared Hybrid • A hybrid design can be used to allow I/O control registers to be ports, but have their data buffers as the address space Capt MWP LeSauvage

  15. Direct Memory Access (DMA) • DMA is used to free up the CPU from moving bytes of data from devices to memory • It requires another piece of hardware in the system called the DMA controller • The OS/CPU loads the DMA controller’s registers with the information needed to instruct it from what device to get/put the data, where in memory to start writing/reading and how many bytes are to be read/written Capt MWP LeSauvage

  16. Capt MWP LeSauvage

  17. Direct Memory Access • Memory transfer can be byte-at-at-time or burst mode • In byte-at-a-time mode, the DMA controller transfers a single byte (or word) for each request, as just described • In burst mode, the DMA controller transfers a number of bytes at once. This saves time taken to get/release the bus • More efficient, but may delay the CPU from responding to other work/devices for a long time depending on the burst length Capt MWP LeSauvage

  18. Direct Memory Access • DMA controllers usually use physical addresses for their transfers • Otherwise, they would have to talk to the MMU. Particularly tricky if the MMU is ‘part’ of the CPU • Some DMA controllers will buffer the information within their own memory space • Allows for device-to-device transfers, but more complicated • Not all computers use DMA • Not always required and cheaper without! Capt MWP LeSauvage

  19. Interrupts, revisited. • What happens when a device needs attention and signals an interrupt? • Device signals on a line • The interrupt controller, if ready, informs the CPU of a pending interrupt and puts a number on the address bus informing the CPU of which device is causing the interrupt • The CPU uses this address as an offset into a table called the interrupt vector. The entry contained in the table is the address where the interrupt service procedure is located Capt MWP LeSauvage

  20. Interrupts, revisited. • What happens on an interrupt? • Once the CPU is handling the interrupt it acknowledges to the Interrupt controller. Capt MWP LeSauvage

  21. Interrupts, revisited. • Considerations: • On what stack does the CPU save current state? • If the user stack is used, how do we know it is valid? • Similarly, what if the stack is valid, but our information fills the current page? Now we may have a page fault in the middle of our interrupt! • If the kernel stack is used, the CPU will have to TRAP to kernel mode (which isn’t always required...many device drivers live in user space) requiring more time and a full context switch, invalidating the TLB, cache, etc... Capt MWP LeSauvage

  22. Interrupts, revisited. • More considerations: • How much state information has to be saved? • Older systems simply saved the state after the CPU finished its last instruction • Modern systems have pipelines. Do you save only the completed instruction or the state of the partially completed instructions? • Superscalar CPUs are even more complicated. Since instructions are completed out of order and then reassembled, how does the OS/CPU simply restart from a single instruction? Capt MWP LeSauvage

  23. Girl, Interrupted. Wait, what? • Even more considerations: • Some systems provide interrupts that are called “precise interrupts”. These interrupts leave the machine in a well defined state: • The PC is saved in a known place • All instructions beyond the one pointed to by the PC have fully executed • No instruction beyond the PC have been executed • The execution state of the instruction pointed to by the PC is known Capt MWP LeSauvage

  24. Quiz Time! Questions? Capt MWP LeSauvage

More Related